Skip Navigation

[Resolved] Displaying hierarchical pages but only childs and not parent

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to display the brothers of a child post in a hierarchical post relationship.

Solution:

We actually have some documentation on how to achieve this and you can follow the instructions in the link below.
https://toolset.com/documentation/user-guides/views/displaying-brother-pages/

This support ticket is created 4 years, 2 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 11 replies, has 2 voices.

Last updated by pedro.S 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1494059
toolset.png

I have created a CPT called projetos which is hierarchical (similar to pages). See "toolset.png".

I'm using Toolset, Views and Layouts (no content templates, per se).

I followed your tutorial to display brother pages and i'm having some problems, and still, i find that tutorial confusing (althought it appears quite simple).

What i want to achieve is a sidebar in layouts that displays:

When i'm at PROJETO A (parent):

Projeto A 2020
Projeto A 2019

When i'm at PROJETO A 2019 (child):

Projeto A 2020
Projeto A 2019

So whatever page i'm in, i want to always display a list of the child pages of the parent.

What is currently displaying:

When i'm at PROJETO A (parent):

Projeto A 2020 (correct)
Projeto A 2019 (correct)

When i'm at PROJETO A 2019 (child):

Projeto A (wrong)
Projeto A 2019 (correct but missing 2020)

The only way i was able to achieve that the links indeed show up was setting the view query filter to:
Select posts that are related to the Post with ID set by the shortcode attribute id.
eg. [wpv-view name="view-name" id="123"]
Because otherwise it appears blank (thought in Toolset debug it says it found 2 results).

I have provided access to wp-admin but the website is protected by htaccess.
Since you do not provide the box to insert this information i entered the HTACCESS username and password on the FTP DETAILS.

#1494287

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

Thank you for getting in touch. Seeing that you've already setup your child view to filter by the id parameter you should be able to do this.

[wpv-view name='my-view' id="[wpv-post-id item='@{relationship-slug}.parent ']"]

This will work if you add the view to the child post. It will tell the view to list out the other children of the same parent. Replace the {relationship-slug} with the actual slug of the relationship.

Thanks,
Shane

#1494363

Thank you for your help Shane,

There is no relationship slug, or there is? I mean... the only slug i have is the CPT created. There is no Post relationship, there's only a hierarchical structure of the post (similar to Pages).

Or am i missing something?

#1494385

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

Ok thanks for the information.

Try doing it like this then

[wpv-view name='my-view' id="[wpv-post-id item='$parent ']"]

This should pass the correct hierarchical parent information into the view.

Thanks,
Shane

#1494553

Well, i checked and the view is set to filter by the shortcode id, but when i insert [wpv-view name="brothers" id="[wpv-post-id item='$parent']"] into layouts the parent page (PROJETO A) shows the 2 projects underneath it (which is correct) but when i enter one of the projects it displays nothing when it should displays itself and it's brothers.

#1494669

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

The exact issue is that you are on the child post and you want to display the brother pages of that child post correct?

Could you try using the Post Parent filter in views ?

This filter is specifically for relationships like this.

Also could you send me a screenshot of your view filter section on the backend.
Thanks,
Shane

#1494759
toolset2.png
toolset3.png

Check the attached images.

When i open PROJETO A page (check the hierarchy on my 1st post), i can see the list of both child posts correctly.

But when i open a child project (ex: PROJETO A 2019) nothing is presented at the moment with the code you provided. It should present me with the list of all the child projects of PROJETO A.

#1494839

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

Thank you for the screenshot.

Based on your setup, it should work.

Would you mind allowing me to have admin access to the website so that I can have a look?

The private fields will be enabled for your next response.

Also please let me know the layout that I should be looking at.

Thanks,
Shane

#1494909
#1495147

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

This should now be working.

Could you have a look at let me know if everything is ok now ?

Thanks,
Shane

#1495207

Thank you Shane! It appears that yes it's working, but i'm quite intrigued of what was i doing wrong?

#1496341

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pedro,

You actually setup everything correctly.

The only issue I found is that using the word "id" as the shortcode parameter didn't work. I suspect that this is because the word ID is being used elsewhere in the shortcode as an identifier. All I did was change the parameter name and it worked.

Thanks,
Shane

#1496469

Thank you for your time Shane, i really appreciate!

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