• I want to adjust some html and text on a page that a plugin generates.

    Rather than edit the plugin’s files, I would like to do a search and replace on the content, like this:

    function replace_content($content)
    {
    $content = str_replace('replace this', 'with this',$content);
    return $content;
    }
    add_filter('the_content','replace_content');

    I can put that in my functions.php and it works fine…. however, it seems rather wasteful to run it sitewide, so I’d like to run it just on the pages the plugin generates.

    According to the plugin author, the plugin “uses a post type to display what you are seeing. Specifically it’s a mepr-subscriptions post type.”

    So I thought I could do this:

    if (is_singular('mepr-subscriptions') {
    // (search replace here
    }

    but that didn’t search/replace

    So I tried this:

    if (get_post_type() == 'mepr-subscriptions') {
    // (search replace here
    }

    and this:

    if (get_post_type($post->ID) == 'mepr-subscriptions') {
    // (search replace here
    }

    But that didn’t search/replace on the plugin page either

    So I checked the post type by doing this:

    $post_type = get_post_type( $post->ID );
    echo $post_type;

    and got the result:

    memberpressproduct

    So I switched the codes above to using that as the identifier (instead of mepr-subscriptions) and they still didn’t work.

    Where am I going wrong here?

  • The topic ‘Trying to use an IF statement to single out a plugin page by post type’ is closed to new replies.