• Resolved artesea

    (@artesea)


    I’ve got a homemade plugin which replaces
    <!--phrase-->
    with
    Here is some clever stuff

    <?php
    /*
    Plugin Name: Clever Stuff
    Plugin URI:  https://blog.artesea.org
    Description: Just an example
    Author:      Ryan Cullen
    Version:     0.1
    Author URI:  https://blog.artesea.co.uk/
    */
    
    function clever_stuff($content) {
     global $wp_query;
     if(!preg_match("|<!--phrase-->|", $content))
      return $content;
     else {
      $text = 'Here is some clever stuff';
      return preg_replace("|<!--phrase-->|", $text, $content);
     }
    }
    
    add_filter('the_content', 'clever_stuff');
    ?>

    however I don’t want either too appear in the RSS feed.
    Which filters should I be using to stop it from happening, I’ve attempted to use
    remove_filter('the_content_rss', 'clever_stuff');
    but “Here is some clever stuff” still appears in the RSS file.

Viewing 1 replies (of 1 total)
  • Thread Starter artesea

    (@artesea)

    Managed to solve this by using the bool is_feed() inside the function to replace <!--phrase--> to blank.

    <?php
    /*
    Plugin Name: Clever Stuff
    Plugin URI:  https://blog.artesea.co.uk/
    Description: Just an example
    Author:      Ryan Cullen
    Version:     0.2
    Author URI:  https://blog.artesea.co.uk/
    */
    
    function clever_stuff($content) {
     global $wp_query;
     if(!preg_match("|<!--phrase-->|", $content))
      return $content;
     else if(is_feed()) {
      return preg_replace("|<!--phrase-->|", '', $content);
     else {
      $text = 'Here is some clever stuff';
      return preg_replace("|<!--phrase-->|", $text, $content);
     }
    }
    
    add_filter('the_content', 'clever_stuff');
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘the_content filter but not in an RSS feed’ is closed to new replies.