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:
- How to make a image-size selected by default in Media upload – WP v3.5
- Remove “Insert from URL” link in Media upload – WP 3.5
- How to change the wp-login.php page title?
- adding a filter to a shortcode?
- Hide custom image sizes from media library
- Permanently remove first image from posts
- Change the footer text on the login page
- add_filter to post-gallery and remove all ‘s?
- How to overwrite youtube embed?
- Rewriting search and pagination base
- Filter the blog title displayed in the header
- Display only text to WordPress loop without loosing the text formatting
- Remove class that has been added by parent theme
- append PHP function to the_content
- body_class filter – Is there a better way to write this code?
- How to add Shortcode (font awesome) in widget title?
- How To Change The Html of Products filtration sidebar in Woocommerce?
- Filter get_the_title to remove certain characters?
- Wrap First Character after in a tag
- Get posts with at least one category in common with current post?
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- Change the site tagline (or similar) based on current page
- Get_avatar filter?
- WooCommerce Related Products by Attribute
- Custom filter in admin edit custom post type responding with invalid post type?
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Input type search in Menu
- add_action shortcut?
- Is it acceptable to treat a filter like an action?
- Edit incorrect password message WordPress
- Add data attribute to each li in menu
- Ajax category filtering products default show all
- Add a specific part of current category page url to shortcode
- Why does my callback function not work with this custom filter hook?
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Remove the first 5 characters of the_title and orderby that
- Print last modified date only on posts
- How to add an arrow to menu items has submenus
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Unique icons next to each WordPress menu item
- Change tinyMCE editor to allow marked content when pasting from Word
- How to debug this search & replace strings snippet?
- Hide Featured Image Meta Box on Editor Screen
- Add item to top of menu using a filter in functions.php
- How to make modifications only to certain elements of an HTML string on the server-side?
- Override a function defined in wp-includes/comment-template.php
- Content filter won’t work
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- How to append to an array and return the results in a filter?
- Get the_content surrounded by instead of
- wrap a span tag around author’s post count
- Displaying content on posts page based on category
- Can I remove or edit an include() from a function with a filter?
- Dynamically adding filters
- WordPress doesn’t load HTML
- apply_filters with several different values?
- How can I modify this code to make the search box include tags and meta
- How to sort WooCommerce products page by latest in-stock items first?
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Show related products by attribute based and certain conditions
- How to Create custom block for displaying information in content section which act like shortcode
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Filter ‘comment_notification_text’ not working
- How to run php code only for a specific widget on a page and not all widgets on that page?
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Change the “Show All” button in a WordPress Portfolio Filter
- Change lost password url to a mailto URL in WordPress
- Shortcodes not processing inside post content
- Remove span tags from WooCommerce Downloads page
- How to edit post meta data before publishing the post it self wordpress?
- Add a top bar to a wordpress theme without editing the header.php file?
- I want to hide “sold by” on certain pages with id page 43
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- using filter and hook inside class
- How to bind each “the_content” elements to a custom variables
- How to change href of a Widget menu item link?
- Reload page with a different shortcode when a user selects from a dropdown
- Filter portforlio with librairie isotop
- WordPress Ajax filter: Create two loops for different output styles?
- add_filter() inside another add_filter()
- Redirecting the lost password page request when using a custon login page
- How to display custom seo title before the loop?
- Custom Bulk Actions handler not firing
- How to generate customized filtered output for the gallery
- dynamically change content of div with php
- How to remove title tag with this filter
- str_replace not preserving whitespace
- How to apply filter
- Add custom filter to register data in array
- Get terms of the posts with one query
- Woocommerce Price Text
- Limit Taxonomy Parents
- Display a post based on its metabox selection
- Search box background on a different page template
- dynamically filter by category via sub-menu
- How to change wp-admin and wp-login urls
- How to add different menu items on different menus?
- Custom Filtering date with newsletter