Skip Navigation

[Resolved] Show only posts in WP_Query that have a post relationship

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by Minesh 4 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#1495819

Hi Toolset,

I have two custom post types A and B. They have a many-to-many relationship.

In the taxonomy template of A i would like to show only posts of A which have a relation with B. If no relation is show the post of A needs to be hidden.

How do i do this?

Thanks,
Menno

#1496085

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you mean that you have post type A and B + taxonomy X is assigned to post type A.

And you want to display posts of post type A (if and only if they have any connection with post type B) on taxonomy archive X?

#1496243

Hi Minesh,

Thanks for your response. I have a loop where i show items from post type A > Product and within that loop i have another loop of data from post type B > Price. I have a price compare site so i have multiple B posts that have a relationship with A. But i only want to show the product if there is a price available.

Do you understand it? 🙂

Thanks, Menno

#1497797

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - thanks for the information.

Do you mean that you have nested view's added, view inside view? If yes, I need to check your view structure first.

Can you please share the problem URL where you want to display those views?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1497977

Hi Minesh,

I use custom code and not the Views plugin. But in fact it's a view in a view.

The query must be something like: Query all posts from A that have a relationship with post type B.

#1497983

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Sorry, what kind of custom code you are using?

Can you please share the code so I can get the idea of what exactly method you are using for the view inside view?