Home › Toolset Professional Support › [Resolved] Display content from post relationship using custom field and custom taxonomy
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 16 replies, has 2 voices.
Last updated by dbarber 1 year, 7 months ago.
Assisted by: Minesh.
I have two custom post types with a many to many relationship.
Both post types have custom taxonomies.
I have a custom field that's relative to the relationship between the posts.
I want to display content based on a combination of a custom taxonomy and the custom field.
I have view that filters for the relationship between the posts and I have tried to use a combination of the custom taxonomy and the custom field as shortcode atttributes in a view to display the content but it does not work.
I've tried everything I can think of but I couldn't get it to work.
In the end, I created another custom field for the relationship and am able to get the result I wanted but I can't help but think I must be missing something.
Here's a page where I am using the custom fields for a post relationship (where I had wanted to use the custom taxonomy):
hidden link
In this example, finalists and award programs are related custom posts. And I am using the following custom fields from the relationship as shortcode attributes to get them to display on the award program page (also on another page).
So it works as it is now but I would like to know if it is (should be) possible to use a combination of the custom taxonomy and the custom field as shortcode attributes to display the content because that would be more efficient (and it seems to me that it should be possible).
I've been working on this over the course of the weekend and it looks like the shortcode attribute based on the custom field in the post relationship has no effect.
I removed the attribute and now the related posts do appear.
But I am unable to get the shortcode attribute to work on another post where I need to display related posts filtered by a shortcode attribute.
Here's a link to an example (and the staging environment:
hidden link
The custom posts are:
- Award Programs
- Profiles
I have set up a many-to-many relationship between them with the following custom field in the relationship: Chapter Type.
There are four options for chapter type: Small, Medium, Large, and International.
I have a view for chapter profiles with the content selection set to Profiles.
There are two query filters:
One is for post relationship (currently set to any relationship for the post where the view is shown, but I have tried others, with no success).
The other is for the Awards Profiles relationship custom field (Chapter type). It's set to use a shortcode attribute (in this case chaptertype).
The loop editor uses just [wpv-post-title]. I have tried item=@ options with no success.
I've got the shortcodes embedded in a content template for Award Programs and, in the example provided in this post, the first two chapter types (Small and Medium) simply use the view shortcode (no attribute). The other two (large and international use the with with the shortcode attribute - e.g.,
[wpv-view name="chapter-profile" chaptertype="Large"]
The post itself does have all of the chapters along with the custom fields for Chapter type set correctly.
But, as you can see, the chapter types without the shortcode attribute output everything (all chapter types) and the chapter types without the shortcode attribute output nothing.
Please advise.
Thanks
Dawson
Hello. Thank you for contacting the Toolset support.
When you have content with many-to-many post relationship and you want to filter your view with intermediary post type custom field your view should to set to query intermediary post type, in your case Chapter Type.
Can you please share problem URL where you added your view and admin access details and let me review your current structure and get back to you will the possible solution.
*** 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.
Hi Minesh
I'm not sure if more details help or not, but I thought I'd share with you what I had originally wanted to do.
I want to be able to feature details from Profile custom post types within Award Program custom post types as well as within Annual Awards custom post types.
Specifically, I want to add Profile posts as "finalists" to Award Program posts for an individual year. And then I want to add Award Program posts to annual Award posts for that same year.
I want to show information from Profile posts within Award Program posts and within Annual award posts.
As winners will eventually be selected from the finalists - and finalists and winners can be named for different award programs over different years - I used a custom field (Award Status) in a post relationship to allow for the changing of the status from Finalist to Winner.
That will also make it easy for my client to update, since I have created a View that will append the Profile title with a dash and the word Winner simply by ticking the Winner radio button in the Award Status custom field.
Since one award program (Chapter of the Year) has four different categories (small, medium, large and international), I also need to be able to show information from Profile posts in Award Program post and Annual Award posts seperately, by category.
I had hoped to be able to use a combination of Award Program post custom taxonomy (Chapter Category) and the Award Status custom field in combination as shortcode attributes along with the View to display this but, after many attempts, I figured that the two could not work in combination. Or maybe I just couldn't figure out how to make it work.
Cheers
Dawson
Thank you for sharing admin access details but when I try to login it shows that it send the login authentication code to email.
Can you please remove this additional authorization so that I can login to the admin and check your structure and get back to you with possible solution.
I have set the next reply to private which means only you and I have access to it.
Sorry, Minesh
I've disabled 2FA so you should have no problems logging in now.
Cheers
Dawson
I've added the custom field query filter with your following view at "Query Filter" section:
=> hidden link
Select items with field:
Chapter Type is a string equal to VIEW_PARAM(chaptertype)
now what if you try to check with the following shortcode:
[wpv-view name="chapter-profile" chaptertype="Large"]
Does it works as expected?
Hi Minesh
It seems that the view "ignores" the filter.
Please see the screenshots.
As the backend images show, there's only one chapter designated as "large" yet the view, with the filter set to large, shows all chapters.
When I checked in the content template where you added your view:
=> hidden link
I see you have added view as given under:
[wpv-view name="awards-chapter-profiles"]
You forget to pass the shortcode attribute:
So, I've changed the above view as given under: chaptertype="Large"
[wpv-view name="awards-chapter-profiles" chaptertype="Large"]
I can see its working as expected:
- hidden link
Hi Minesh
I don't know how I missed that one. Thank you!
If you don't mind, I am going to leave this ticket open until after I am able to resolve what I believe is a related issue (displaying grandchildren - i.e., profiles and chapter profiles - posts on a related post - i.e., annual awards).
I have done it before (on the same website) but I haven't been able to get it to work so far. Now that you've cleared this up for me, I think I should be able to get it sorted on my own.
I'll be sure to close this ticket if I am able to resolve it. Otherwise, I'll let you know.
Thank you!
Yes, Sure. You are welcome to mark resolve this ticket when you can.
Hi Minesh
It looks like I do need your help again after all.
You managed to solve the problem I was having on this page:
hidden link
Basically, I couldn't figure out what I needed to do to get the shortcode attribute to work in a view.
I'm having the same problem doing the same thing on this page:
hidden link
I've tried everything I can think of and I just can't get it to work.
That page represents a post type (Annual Awards).
Annual Awards have a many to many relationship to Awards Programs.
And Awards Programs have a many to many relationship to Profiles.
Can you tell me what I am missing?
P..S. I will need to give you login credentials again, as I recently copied the production environment over to the development environment, which wiped out your account. So please give me an option to do a private reply.
Thanks
Dawson
.Please share problem URL and admin access details.
*** 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.
Annual Awards custom post type on which I want to display chapter profile finalists by chapter type (small, medium, large, international): hidden link
===>
I would like to know how to know who is the finalist - is there any field for that? And with above page you want to display posts from post type chapter profile - right?
I see the view is set to query post type "Award Programs":
=> hidden link
Can you please explain this all and I'm happy to guide you in the right direction.
Hi Minesh
Sorry for the oversight. They are all finalists. But I added a custom field to the post relationship to define their status so that when winners are announced, the client simply needs to update the status by checking the winner radio button.
Here's the Awards Program CPT for 2023 chapter of the year, with the post relationships defined:
hidden link
And, yes, with the page you referenced I want to display the chapters by chapter type as they are here:
hidden link
I'm not sure if I have the view that's set to query post type "awards programs" is set up right (or if the nested view within it is the problem - or perhaps they are both set up wrong).