I am trying to: Display a list of custom posts, filtered by a custom taxonomy.
What is happening: This works fine for the most part, but on one taxonomy page its including two taxonomies instead of just the one.
My view displays a list of custom posts, filtered by a custom taxonomy. This works fine for all but one taxonomy page.
The view filter is set as follows:
Select posts with taxonomy: Programs the same as the page where this View is shown
'Programs' being a custom taxonomy.
I have a page the lists these taxonomies, and a user can click through to a 'program'.
For example, a user clicks the link for '.../program/program-rmct/'
This should show all posts with the taxonomy program of 'program-rmct'.
This works fine on all other programs except this one. For some reason on this particular one, it's including content for the program taxonomy 'program-vclc'
I'm also seeing strange redirects to the home page from time to time when viewing one of the program pages.
It shows a 404, then redirects to home. If I force refresh, then sometimes it starts working again. Not sure if this is related. It's intermittent, and may have just been a caching issue. Not the main concern.
If you take a look at the screenshots attached, I'm showing the following:
- screenshot 1 - shows home page list of all 'program' taxonomies that the user has access to.
- screenshot 2 - shows the program-vclc taxonomy - this is working as expected.
- screenshot 3 - shows the program-rmct taxonomy - note ow the breadcrumbs list "REAL Marketing Core Training, Virtual Coach Learning Centre" - this is a shortcode listing the current taxonomy. Somehow it's including both of these in the view.
- screenshot 4 - shows how I have the view filtering setup
Hi, as it is set now, the filter is checking the current page, i.e. a Program post, and determining which Program taxonomy terms are associated with the Program Post. Then it's filtering the View of Program Sections by those same Program taxonomy terms. That seems a bit odd, because you would have to have the Program taxonomy applied to the Program post type. If that is your intention, then the current setup is fine. You should verify that the Program post has the appropriate Program terms associated with it in order for the View of Program Sections to filter by the correct terms.
You could do this in a more automated fashion without applying the Program taxonomy to the Program post type. Configure the Query Filter to filter by Program taxonomy term, but set it up so that the term filter is set by a shortcode attribute. Then pass the Program post slug into the View shortcode, something like this:
[wpv-view name="your-program-post-view" wpvprogramtax="[wpv-post-slug]"]
See the attached screenshot for an example of this type of Query Filter. My taxonomy is called "Book Tax" but yours will be "Program" or something else.
This approach means you don't have to associate the Program taxonomy with the Program post type, and you don't have to assign Program terms to each Program post. On the other hand, it also means that you must be sure the Program taxonomy term slugs are identical to their corresponding Program post slugs. In other words, on the /program/program-vclc post page, you want to show Program Section posts that have the Program taxonomy term "program-vclc". But if your term slug is actually "program-vc-lc" then this approach won't work - the slugs of the Program terms and Program posts must be identical.
Let me know if you have questions about this, or if I misunderstood what you want to accomplish.
One thing I neglected to mention - it's usually a good idea to uncheck "Don't include the current page in query result" in the View editor when the View displays a different post type. Otherwise you can get some unexpected results.