Skip Navigation

[Resolved] Post Navigation Based on One to Many Relationship

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.

This topic contains 17 replies, has 3 voices.

Last updated by Jaime 11 months ago.

Assigned support staff: Minesh.

Author
Posts
#1955931

Tell us what you are trying to do?
I would like to show a Post Navigation but only to the child posts related with the Parent Post. Is this possible?
I give you an example.

My website is about Touristic Routes in Cinema Locations. So, I have several Routes including several Locations. Let's say I have a route about "Sean Connery" and one route about "Lawrence of Arabia". When I go to "Sean Connery" route, the Route displays 5 locations. I would like to show Navigation Posts only for those 5 locations.

Besides, the Route about "Lawrence of Arabia" contains 7 locations. I would like also to show Navigation Posts including this time those 7 locations.

Note that two Routes could include the same locations inside. For example "Sean Connery" would include "Almería Beach" and "Lawrence of Arabia" will also include "Almería Beach" as a child post. So, the issue here would be to show Navigation Posts only for the Posts related with the Route coming from.
Is this possible?

Is there any documentation that you are following?
Well I saw, this two tickets, and try them but I'm not sure if the problem is exactly the same. Besides, I'm not sure how how really implement the code.
https://toolset.com/forums/topic/previous-next-within-parentchild-relationship/
https://toolset.com/forums/topic/next-and-previous-sibling-posts-in-a-one-to-many-post-relationship/

Is there a similar example that we can see?
I'm not sure.

What is the link to your site?
You can see a website online with the posts and relationships here.
hidden link (Routes - Parent)
hidden link (Single Route displaying "Locations" related (child) below.

* Now I'm working on an development site trying to add Elementor as Page Builder. If the solution could be thought with Elementor as Page Builder, that would be great. I guess the Page Builder is not a problem here, but just in case.

#1956373

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Let's first just clarify what you are aiming to do.

If I visit the sean-connery ruta link, there is a slider showing location posts (it looks like there are about 17 locations that are children of the sean-connery post).

Is your objective that if, from this page, someone clicks a link to one of the locations, while viewing that particular location they see previous and next links to navigate to the other location posts which are also children of the sean-connery ruta? (The links may be different if they arrived from a different ruta post.)

If that is the case, one way to implement this would be using a variant of the code from the other thread. Another, without custom code, would be to change the links to the locations in the slider so that instead of pointing to the actual individual location posts they pointed to a page containing a View of child locations that showed only one location at a time, essentially paginating through the View results to give the appearance of navigating through the single posts. You would manage this by modifying the links to use URL parameters, but the complication here is that it requires using legacy Views as this is not yet supported in the Blocks interface.

So first, please confirm this is what you are aiming for, and second, do you have a preference for managing this with a code solution or using something like the above, with the legacy Views editor.

#1956559

Hi Nigel.
Thanks for your answer.
You understood perfectly well.
What I'm aiming to do is just what you described about locations on Sean Connery's Route.

I'm still using Views so, for me it's not a problem to use any of the options you described.
So, I let you to decide what of the options would be more efficient or easy to set up.

Thanks Nigel!
🙂

#1957653

Minesh
Supporter

Languages: English (English )

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

As Nigel pointed out with his previous reply:
- https://toolset.com/forums/topic/post-navigation-based-on-one-to-many-relationship/#post-1956373

To navigate through the child locations - we can modify the link in the slider so that it should redirect to a page where we will add a view that should display the related locations with pagination. If that is Ok for you, you should send me temporary admin access details and I will create a page with view to demonstrate you.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.

#1958077

Minesh
Supporter

Languages: English (English )

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

I will require little bit more information here.

The Ruta "lawrence-de-arabia" has 11 related locations as I can see with the post relationship box "Rutas M2M Localizaciones":
- hidden link

And on the frontend it also shows the 11 related locations with image where it displays 3 results per page on middle of the following post:
- hidden link

Am I missing anything here or could you please guide me what exactly you want here.

#1958369

Hi Minesh.
Thanks for your answer.
Sorry, I think I make a mistake with the View names I provided to you before.
Maybe is that what it confussing for you. I apologize for this.

Let me clarify again and I hope this will make you understand better.

1) Yes, Ruta "Lawrence de Arabia" has 11 related locations.
2) This locations are shown inside "RUTA Single" (an Elementor Template) with "LOCALIZACIONES (sin Mapa) en Ruta -> (2A2)" (a Toolset View)
3) What I need is when a user clicks on any of those related "Localizaciones" the web displays the Post (in this case "Localizacion") with Pagination only for the posts related with the Route.

Is clear for you now?
If don't, please tell me and I'll try to do my best to clarify better for you.

Thanks Minesh

#1958395

Minesh
Supporter

Languages: English (English )

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

3) What I need is when a user clicks on any of those related "Localizaciones" the web displays the Post (in this case "Localizacion") with Pagination only for the posts related with the Route.
==>
Do you mean, when user click on any of the listed 11 related posts by view "LOCALIZACIONES (sin Mapa) en Ruta -> (2A2)" - it should redirect to single location post and on single location post you want to display prev/next link of pagination which should be limited to those 11 related posts?

#1958399

Yes Minesh.
That's exactly what I need.

I will need to make this for several Views, but with your help for this one, I'll make the rest of them.
But, yes. You understood perfectly what I need.
🙂

#1958471

Minesh
Supporter

Languages: English (English )

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

Ok but the workaround shared by Nigel is not to go on single location post BUT we will create a new view that should display the related locations, it will be kind of the same view that displays all related 11 locations currently on your single Ruta post, the difference will be we will create that new view that display related locations and you should configure the loop output like single location post and we will display 1 post per page.

Will that work for you?

So basically, you will have a page that display the related location post 1 per page using view. It will not be a single location post.

#1958491

Yes, I understand. So, we wil have a Page containing a View that displays one post and has a Navigation to the Next / Prev post, right?
I think this could be enough.

The main problem here was I need a Pagination between related posts, so I think this could be a good solution.
Let's try this, Minesh.
And thanks for all your support!
🙂

#1958495

Minesh
Supporter

Languages: English (English )

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

I've created the following view - you can adjust the "Loop Editor" section and add whatever fields you want to display and format the output as required:
- hidden link

On the following page - I've added the above view:
- hidden link

And within the Loop Editor of the following view I've changed the links as given under:
=> hidden link

<div class="panel-header">
    <a href="/related-locations/?wpv-relationship-filter=[wpv-post-id item='$current_page']">[types field='imagen-principal-localizacion' align='center' size="custom" width="650" height="500" crop="true" class="image-localizacion-panel-ruta"][/types]</a>
  </div>

Now, on the frontend:
- hidden link
When you click on any related location, it will redirect you on /related-locations/ page where it will display 1 post at a time. You just format your output as required.

#1962387

My issue is resolved now. Thank you!

#1963041

Hi Minesh.
Sorry for reopening the ticket, but there is something not working properly.

The problem is when I click on any of the related locations displaying on the Route, it always open the first of the Related Locations. This is not an expected behaviour, right?

You can see it in here:
hidden link

If you click on "Alcazar" (second location) it will open "Desierto de Tabernas" (first location on the row). The same issue for any location. It always open the first one.

Can you check this for me please?
Thanks!

#1963591

Minesh
Supporter

Languages: English (English )

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

Ok - got it.

You will require to share admin access details as system used to automatically delete the private information (access details) once user mark ticket resolved.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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.

#1963877

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

With the following view:
hidden link
- I've adjusted the URL params we pass as given under:

 <a href="/related-locations/?wpv-relationship-filter=[wpv-post-id item='$current_page']&wpv_paged=[wpv-loop-index]&wpv_view_count=6251">[types field='imagen-principal-localizacion' align='center' size="custom" width="650" height="500" crop="true" class="image-localizacion-panel-ruta"][/types]</a>

Can you please confirm it works as expected.