WordPress.org

Ready to get started?Download WordPress

Forums

Disable Contextual Related Posts Plugin on Custom Post Types (5 posts)

  1. USOBlogger
    Member
    Posted 2 years ago #

    Hi Everyone,

    I am not too adept at php, and I am having an issue with the Contextual Related Posts plugin on my site.

    It works great for my blog and I love the plugin; it even offers a setting to disable it on certain categories. However, this doesn't work for custom post types.

    I'd like to disable the plugin on my directory listing pages, i.e. http://www.wpbeventhall.com/directory/culinary-flair

    Can anyone help me? I have a feeling it's a real easy fix, but I just don't know how to do it!

    Sincere Thanks,

    Lauren N Bridges

  2. stevemagruder
    Member
    Posted 2 years ago #

    It's pretty easy, but you have to edit the contextual-related-posts.php file...

    Around line 80, you'll see:

    $output = '<div id="crp_related">';

    Before this, add:

    if (get_post_type() != 'post-type-to-avoid') {

    Around line 138, you'll see:

    $output .= '</div>';

    After this, add:

    }

    That's it. Hopefully, the plugin can be updated to avoid specific post types at some point.

  3. stevemagruder
    Member
    Posted 2 years ago #

    Note that these code changes may not necessarily be the most optimal, but they work.

  4. USOBlogger
    Member
    Posted 2 years ago #

    Hey Steve,

    Thanks so much! I am so sorry for the VERY late response, but I'll be sure to try this & see what happens.

    Thanks again!

    Lauren

  5. funky_buddah
    Member
    Posted 2 years ago #

    I tried it, works like a charm, thanks, Steve.
    But if you update the plugin, remember to redo those modifications.
    Maybe a more skilled person could code a plugin for that if the stars align right or smth :)

Topic Closed

This topic has been closed to new replies.

About this Topic