Skip Navigation

[Fermé] Filter related posts by tag or category

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 3 réponses, has 3 voix.

Last updated by Ghennadi Il y a 7 années et 11 mois.

Assigned support staff: Ghennadi.


Hi there,

I'm trying to display a list of posts in a sidebar. I want the list to be related by tag or category. I'm able to achieve that with a view and some filtering, BUT I'm wondering if it's possible to sort the output so that the posts related by tag appear first, followed by category. Something like this:

Related Posts:
Article 6 (same tag) (same category)
Article 5 (same tag) (same category)
Article 1 (same tag) (same category)
Article 4 (same category)
Article 3 (same category)
Article 2 (same category)

I set up a test site on Here's a sample post hidden link
Currently, the posts are ordered by date. Is what I'm trying to achieve possible?



Here's a post from the dev site for the actual project:
hidden link

I just discovered something. Not sure if I should post to a different thread, but it's related...

In the view for these related posts, my filter is: "Select posts with taxonomy: Categories is Not one of these (Case Study) OR Tags the same as the current page."
But for some reason, The Case Study post is still getting displayed in the sidebar. Any idea why?

I'm having the same problem with Case Study posts: hidden link
Posts from the Articles category are getting displayed. They should be getting filtered out.

Why aren't my category filters working?

Does the fact that I'm dynamically adding a category to my custom post types have something to do with it?

	function add_articles_category_automatically($post_ID) {
		global $wpdb;
			$cat = array(158); // Articles category
			wp_set_object_terms($post_ID, $cat, 'category');
	add_action('publish_articles', 'add_articles_category_automatically');
	function add_case_studies_category_automatically($post_ID) {
		global $wpdb;
			$cat = array(159); // Case Studies category
			wp_set_object_terms($post_ID, $cat, 'category');
	add_action('publish_case-studies', 'add_case_studies_category_automatically');

I'm doing that so I can use the category filter on a search here: hidden link

That way my client doesn't have to manually assign the category for the post type each time the write a post.



Luo Yang

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi Eric,

Thanks for the details, I am working on it now, will feedback if I find any thing


Dear Eric,

I’ll send you a private email right now asking you for some private information that will help me setup correct views for you. Please check your email in a couple of minutes, and if you don’t get it, let me know so I can send it again.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Le sujet ‘[Fermé] Filter related posts by tag or category’ est fermé à de nouvelles réponses.