Title: Replace content
Last modified: March 7, 2019

---

# Replace content

 *  Resolved [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/)
 * Hello,
    I need to use **str_replace(‘xADDx’, ”, $content)** to delete the tags
   I use in the content to show adds in regular pages, but I can’t find where to
   do that in the AMP Plugin files.
 * Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11288494)
 * How is the ad markup being added to the pages in the first place?
 * There is no way to directly use `str_replace()` to replace content. It is better
   to use a conditional like:
 *     ```
       <?php if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) : ?>
           <amp-ad>...</amp-ad>
       <?php else : ?>
           ...non-AMP ad code...
       <?php endif; ?>
       ```
   
 *  Thread Starter [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11288541)
 * When I’m writing my entry in the wp editor, I just put xADDx in the middle of
   the content in the place I want the advertisement to be shown. That’s why I need
   to replace xADDx for nothing in AMP.
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11288557)
 * If it’s in the content then you can just use the `the_content` filter. I don’t
   know the specifics of how that replacement happens to begin with, but you could
   this code in your theme’s `functions.php`:
 *     ```
       add_filter( 'the_content', function( $content ) {
           if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
               $content = str_replace( 'xADDx', '', $content );
           }
           return $content;
       }, 1 );
       ```
   
    -  This reply was modified 7 years, 3 months ago by [Weston Ruter](https://wordpress.org/support/users/westonruter/).
 *  Thread Starter [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11288619)
 * I tryed that in my child functions.php and in the wp-content/amp/includes/admin/
   functions.php and it didn’t work.
    But I saw that in my child theme I had an “
   AMP” folder with footer.php and single.php. In single.php I changed this: `<?
   php echo $this->get( 'post_amp_content' ); // amphtml content; no kses ?>` for
   this: `<?php echo str_Replace('<p>xADDx</p>', '', $this->get( 'post_amp_content'));//
   amphtml content; no kses ?>` and now it doesn’t show xADDx
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11288660)
 * That isn’t the right `functions.php` file. It should be the one at the root of
   your theme.
 *  Thread Starter [roxer82](https://wordpress.org/support/users/roxer82/)
 * (@roxer82)
 * [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11294219)
 * Ok. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Replace content’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

## Tags

 * [content](https://wordpress.org/support/topic-tag/content/)

 * 6 replies
 * 2 participants
 * Last reply from: [roxer82](https://wordpress.org/support/users/roxer82/)
 * Last activity: [7 years, 3 months ago](https://wordpress.org/support/topic/replace-content-2/#post-11294219)
 * Status: resolved