get_extended() saved me! The returned array has ‘main’ and ‘extended’ keys. Main has the text before the <!--more-->
. The ‘extended’ key has the content after the <!--more-->
comment.
$content = get_post_field( 'post_content', get_the_ID() );
$content_parts = get_extended( $content );
echo esc_html( strip_tags( $content_parts['main'] ) );
Related Posts:
- Display random categories on the front page (Finding and Editing Theme Functions)
- is_customize_preview() like function to check if Customizer “Live Preview” in JavaScript
- Some questions about how proper add 2 CSS file in a WordPress theme?
- “options.php” not found
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Add custom css to theme
- How to get postId from the argument $block when register_block_type()?
- remove_action on after_setup_theme not working from child theme
- How to load scripts/styles specific for a page
- Using classes instead of global functions in functions.php
- Child theme – Overriding ‘require_once’ in functions.php
- Is it ok to use a function to output the text domain name in a wordpress theme
- Issue with get_theme_mod returning a blank value instead of the saved value
- TinyMCE custom styles remove class when switching styles
- Hourly Routine Not Firing ( wp_schedule_event() )
- Passing variables to templates (alternatives to globalizing variables)
- Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- Overriding core functions in child theme
- Theme Demo in live Site
- Dequeue Scripts and Style for Mobile not working?
- Customising widget titles/headings in WP 5.8
- Design view breaking on Pages
- Returning Variables back into a template
- Displaying Widgets
- Theme-Config tab in admin Pannel?
- Best Practice for Syncing Local Development With Staging Development [closed]
- Overwrite Parent Theme add_image_size in Child Theme
- Is It wrong to use oop approach on functions.php?
- PHP files included in functions.php don’t seem to work
- When using wp_enqueue_script(); in a theme why don’t we use add_action?
- Defining a global array in functions.php?
- How to use Internationalized human_time_diff() function in Chinese?
- is_dynamic_sidebar always returns true while using Jetpack visibility
- Hook specific functions if on a specific admin page
- Set WordPress Default Template
- How can I change the do_action function in footer (copyright area)
- functions.php mistakenly deleted
- Echo tags used to describe the theme
- Add caption functionality to custom WordPress theme
- Override a theme function in a child theme?
- changing behaviour of get_search_form
- Pulling Twitter RSS feed not working as expected (fatal error)
- How to load jQuery in the footer – nothing works for me
- Use register_setting() in a loop
- Create a new query in function.php to filter blog posts
- Add dynamic links in WordPress custom theme
- WordPress website Rs changed to currency symbol
- WordPress menu link doesn’t work properly
- Search filter by Post title OR Meta Title Value [duplicate]
- admin-ajax.php + load-scripts.php hanging for minutes
- Functions in custom theme
- Unique sequential reservation code
- Functions.php Problem
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- Control the srcset much more (not all sizes in it each time)
- Way to store featured image width and height in two separate variables?
- Excerpt for pages not showing
- Turn get_posts as string into an array for use in theme admin options
- Passing global variable from header.php to functions.php
- Functions php shortcode for displaying main menu with no child items
- PHP 7.1 | Warning: A non-numeric value encountered in
- Can’t switch to a child theme using filters template, option_template and option_stylesheet
- I can’t add CSS with functions.php
- Default Nav Highlight
- WP Customizer API loaded into functions.php
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- contact form in template with jquery,validate and ajax
- How can I assign separate stylesheets to different pages?
- Can’t change theme name
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Dynamically switch file in get_template_directory_uri() | Function [closed]
- Astra theme – cannot set short product description under the product title (product name)
- Exclude specific post from query
- Advanced method to control cache of enqueued style/script
- Header menu aligned right on all pages except for single-post page [closed]
- Override category archive page title (not the head title)
- Class parameter in get_avatar args doesn’t get added to output
- Is_Page doesnt detect my page
- Test CDN link from function.php or wp_enqueue_script/style?
- How to customize archive widget only for cpt?
- Add meta data in head from theme
- what is `get_section()` and how to use it?
- Shortcode Initialization in a Custom Theme
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- Getting back a blank WordPress site following functions code edit
- How to pass a variable from a template page to the child theme functions.php
- wp_nav_walker that interacts with widgets to setup mega menu
- Settings in functions.php used by a plugin
- Query custom post type and showing its content
- Register a widget area when a theme option has been saved?
- Allow tags and attributes in post and pages content
- Additional Sidebar
- How do I access variables outside a function [closed]
- Why functions metaboxes is causing White Screen in Admin [closed]
- Getting error on function.php
- Adding function to function.php error 505 [closed]
- How to automatically load Google Fonts on pages only as they’re used?