Skip Navigation

[Resolved] Post appearing twice because of multiple contexts

This support ticket is created 3 years, 10 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Waqar 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1613803

I have CPTs Books and People with a many-to-many relationship.

In the Books archive, I display the author(s) of each book with a special People View, and that works fine.

In the single Person display, I have a view that shows all the books authored by that person, and I use the same People View to show the authors of each book.

The problem is that in that context, the name of the person being shown as a Single post appears TWICE as the author of each book.

The special People View that shows the authors is based on an intermediate post type so that I can order the authors appropriately.

However, it seems it is being triggered both by the enclosing view that lists the books AND by the single post display of the person.

I've tried all possible filters on that view (The post where this View is shown, The current post in the loop and The post with ID set by the shortcode attribute), all to no avail.

I've created a video to show me testing this:

hidden link

I hope that makes it cleared.

Alex

#1614837

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alex,

Thanks for asking! I'd be happy to help.

I've watched the video and the issue of the duplicated person name doesn't seem to be related only to the view's "Query Filter" settings.

Can you please share temporary admin login details, so that I can see how this view and the parent content template is set up?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1615745

Hi Waqar

I've just noticed - the issue only appeared on Ken Wilber's page because he had two books listed.
hidden link

It doesn't happen with Zak Stein with only one book:
hidden link

Alex

#1616515

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alex,

Thank you for sharing the admin access.

I noticed that the view "People View as Children of Books - One Line With Links" is set to show the "Books People Intermediary Posts", but with a query filter option "The post where this View is shown".

This makes the view get the intermediary posts related to the current "Person" post that is being viewed.

What you really want here are the intermediary posts related to the current "Book" post with respect to the loop of the parent view "Books View As Children".

Changing to the "The current post in the loop" option in the nested view should fix this.
( screenshot: hidden link )

regards,
Waqar

#1616739

Thanks, Waqar. That did the trick!

But I admit there are still gaps in my understanding. I don't really understand why it was producing the earlier behaviour.

Can you point me to the appropriate document to help me understand this better, please?

Alex

#1620557

My issue is resolved now. Thank you!

#1620781

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Alex,

I apologize I couldn't follow up on this ticket sooner, as we had an unusually busy queue, over the weekend.

It is important to always keep track of the scope of the "current" post when working with content templates and views.

For example, when you'll use the "wpv-post-title" shortcode ( ref: https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-title ) in your single post template "Template for People", it will return the post title of the "Person" post, whose single post page is being viewed.

But if you'll use the same shortcode inside the loop of the view "Books View As Children", the scope of the current post will change to the "Books People Intermediary Posts" and the title of the current post in the view's loop will be returned, instead.

Likewise referring to the screenshot from my last message, the option "The post where this View is shown" in "Query Filter" targets the post, whose single post page is being viewed (i.e. you can call it "global current").

Whereas the option "The current post in the loop" is useful when we don't want to target the post whose single post page is being viewed (or "global current") and only want the current post with respect to the view's loop.

I hope this makes it more clear.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.