You’re overcomplicating things. If you want the_content() to behave as it usually does, then don’t change it via filter or similar.
Just create your new custom function, eg like so (could be placed in your functions.php or if you’re in a plugin somewhere there)
function replaced_content() {
$content = get_the_content();
// $content = str_replace ...
print $content;
}
Then you can use it just like any other function
<div class="main-content"><?php the_content(); ?></div>
<div class="another-content"><?php replaced_content(); ?></div>
Related Posts:
- Apply class to every paragraph that holds image?
- static variable loop not working in WordPress
- Set media upload attachment link to none and hide it in WP v3.5
- How to set custom cookies before output
- How can I hook into and edit the text of a wp_nav_menu tag?
- Rename image uploads replacing “width” and “height” in filename with “medium”, “large”, “small”
- Rename image uploads with width in filename
- How to make an meta_query optional?
- Check if page parent has certain template
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- “Maximum function nesting level of ‘100’ reached” after adding a new filter
- Find variables available at a given hook
- wp_get_attachment_url filter won’t accept two arguments
- Why do filters/actions require an argument count?
- Filter link to existing content suggestion
- Getting my head round WordPress filter
- How to set a custom path, for ajax image upload folder in admin?
- Filter get_the_title to remove certain characters?
- How to use return in my custom function instead of echo
- When using the_author hook, how can I determine the PHP file that generates each call to `the_author()`?
- WordPress php filter admin_body_class not working
- Combine two filters into a single call
- Remove a filter added by a plugin
- Change the site tagline (or similar) based on current page
- Handling Body class based on Template
- WooCommerce Related Products by Attribute
- Add a class to the anchor tag on HTML5 gallery
- add_action shortcut?
- How to control WordPress image metadata (using Imagick)?
- How do I add custom bulk actions to multiple custom post types?
- Show prices with tax in Woocommerce Mini Cart [closed]
- Removing “wpautop” (auto tags) only on certain pages?
- Add filter when image is uploaded?
- Remove the first 5 characters of the_title and orderby that
- Remove a div from RSS feed
- WordPress Gravatar filter is removing my custom attributes
- Alter required message using comment form api
- Add filter multiple times using only one master function
- How to edit php code in WordPress Post file?
- Change page title from page using php via php executed from page/post itself
- Override a function defined in wp-includes/comment-template.php
- Filtering a function’ output for a new continued function
- Deleting Certain terms from appearing on the front end as links
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- Ajax filter button display all posts
- How to have different site identity logos on each page on Astra Theme [closed]
- Custom query vars filters problem with pagination
- Filter by field with array value in ACF on WP REST API
- Get the name of menu item with wp_nav_menu
- update_post_meta() not saving data inside of save-post filter
- How to add aria role and schema markup to custom walker container
- Must filter functions receive all arguments passed to them?
- How to internationalize header image?
- apply_filters with several different values?
- User filter posts by year
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- Remove Author Links
- Apply function.php filter only if url not has /amp/
- How to use apply_filters() inside a plugin class?
- Shortcodes not processing inside post content
- Multiple Tag Filtering
- I want to hide “sold by” on certain pages with id page 43
- Should I set a page as “No-index” if I include it’s content within the front-Page.php via this method?
- WordPress Ajax filter: Create two loops for different output styles?
- How to filter specific element of an array in wordpress/php?
- How to disable sub menu items from being created?
- How can i style “echo apply_filters”
- Adding body class to html tag that already has language attrubutes?
- How to generate customized filtered output for the gallery
- Add class to all meta boxes for a custom post type
- Add a leading zero to pagination
- How to apply filter
- Custom theme: adding unwanted tags in the content
- Apply filters when loading post via ajax
- Woocommerce Price Text
- Limit Taxonomy Parents
- Select All not working in a WordPress search filter
- Custom field in title
- WordPress – show all posts + ones with specific tag
- dynamically filter by category via sub-menu
- Display a list of users with avatar filterable with alphabets
- WXR XML import is stripping php tags that I need to keep
- How to add custom checkout field in user details mail template
- Keeping the previous get value and add another value when submitted
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- For each loop will not append to the_content hook
- Assign new post author IF another user in custom field on post transition
- Blog Posts not sorted and pagination not adjusted after filtering some category
- Modify meta data before saving to database
- How to change wp-admin and wp-login urls
- How to pass value to add_filter wpcf7_form_tag from another function?
- Is there a hook that I can use when a fatal error occurs?
- Changing upload directory temporarily
- WordPress query_posts with multiple tax_query
- Filtering with Attributes – how to display all non-queried products below query