• 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. https://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

Viewing 4 replies - 1 through 4 (of 4 total)
  • stevemagruder

    (@stevemagruder)

    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.

    stevemagruder

    (@stevemagruder)

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

    Thread Starter LNBridges

    (@usoblogger)

    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

    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 ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Disable Contextual Related Posts Plugin on Custom Post Types’ is closed to new replies.