Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello maorb,
    we are both in the same position you have no idea how much im suffering to exclude a category to apera in related posts. My example is i have a video blog and i have a featured category which is selected plus the name of that singer and now my related posts are just a mess, nothing worked for me so far, i tried to exclude it but then posts don’t show up. I am kinda stuck and i have arround 800 posts on my blog. If you find a solution please share it here.

    Thread Starter maorb

    (@maorb)

    @jentor, I still have no solution for that, and I hoped that the plugin developer will visit here and see some problems/requested and consider it for the next version…

    If you find a solution, I’ll be also happy it would be shared here.

    I solved in this way.

    Open wp-related-posts.php and go to line 85. This line has this code:

    foreach ($related_posts as $related_post ){

    Below this line paste:

    $rel_post_cat_id = wp_get_post_categories( $related_post->ID );
    $mycat_to_ban = 1;
    if (in_array($mycat_to_ban, $rel_post_cat_id)) { continue; } else {

    Change number 1 in the second line according to your needs: this is the ID of the category to exclude.

    Now, scroll down to this line:

    $output .=  '</li>';

    Below this line, paste this:

    }

    to close the if loop we added before.

    Save the file and upload it to your server, overwriting the original one (or make a backup of this, first).

    The modification makes this: while the previous lines collect the posts under certain tags, the new lines of code verify if these posts have a given category. If they do have, they will be ignored and the plugin continue on the following record.

    The downside of doing this modification is that when the plugin will be updated, you’ll lose these changes. So it’s better to create a backup of the modified file so to re-add these changes when the plugin will be updated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WordPress Related Posts] Exclude category from related pots’ is closed to new replies.