Exclude 1 category from Similar Posts Block

Posted in: Newspaper
Post count: 57

Hello, I am using a block “Similar articles – by category” after a post. To make those articles random, I am using a snippet 'orderby' => 'rand',

Here is the question: is it possible to exclude 1 category from random posts displayed in that block?

Thank you.

Post count: 7909

Hi,

You can try to replace there with the code I provide to you, so when you have on the post from that excluded category Similar articles block will not show up anymore: http://screencast.com/t/EwLKCr6Fxy7http://pastebin.com/2bJuRYjG

Please replace Uncategorized with you category that you want to exclude and also make a backup of your td_module_blog.php file, in case that you want to revert.

Thanks!

Post count: 57

I still need Similar Articles Block, for those posts as well. In widgets, we have a Multiple categories filter, where we can list all the categories we want:

May be it is possible to use a filter like that with Similar Posts Block?

Post count: 6600

Hi,

Just add an array of categories from which the posts will be pulled, replace wp_get_post_categories($this->post->ID) with and array containing your categories Id’s (array( 10, 14 )), like this: http://screencast.com/t/rpcihU1Eki

Thanks

Post count: 57

YES! Thank you.

Post count: 57

Hey guys, that solution for excluding one category from Related Posts Block (in version 4) was great. Please say how to do that in version 7. Thank you.

Post count: 22421

Hello,

Please follow this topic: https://forum.tagdiv.com/topic/related-posts/

Thank you!

Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic.