Home › Toolset Professional Support › [Closed] Display list of parent posts
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 34 replies, has 3 voices.
Last updated by Christian Cox 4 years, 4 months ago.
Assisted by: Christian Cox.
I don't understand the point of your last post.
I know with a separate view it works OK. The problem is precisely to make the view to work combined with the Archive view.
Please read my first posts and Christian Cox's answers.
The whole point is to display - on a Formations Archive view - a list of Etablissement parents of displayed Formations. Those Etablissements must be filtered by both the Archive native filter (based on what term we're displaying) AND the frontend filters.
Thank you.
Hi Roman,
What I'm saying is that there could be an issue with the actual view that you've placed in the archive.
On a fresh view it filters fine. So what I recommend that you do is to remake the view that is in the Archive and Add it back to the archive.
Once you do this then your view should start filtering fine again with the taxonomies.
Please let me know if this is a little clearer. If there are any concerns you can let me know and i'll be more than happy to clarify.
Thanks,
Shane
You totally mixed up my view... Now I see not only you have deleted its queries, but also you have added a new query that has nothing to do with what I am trying to achieve.
I have restored back the settings as per Christian Cox said I should do:
https://toolset.com/forums/topic/display-list-of-parent-posts/#post-1671423
https://toolset.com/forums/topic/display-list-of-parent-posts/#post-1672651
I did this on both my original view and you test view, but it still does not work. It even seems to me now it's worst than before.
I need to display the list of School IDs that have children Formations displayed on the Archive view results.
Hi Roman,
I checked the view. It is now filtering correctly. I've added the post link to the view to ensure that we are getting the correct data.
I've set the Niveau filter to "-BST 1" to see if all the posts returned would be from the BST 1 selection and it was. So right now you are getting the correct data and the filters are working correctly.
Im now assuming your issue is with the duplicate ID's, this occurs because many of the results share the same parent post and the parent ID is what you are retrieving. As you can see the results of the Post Links are Unique but the id's returned are duplicated.
Each of the items that are being displayed are the ID's of the Formation's Parent post.
Hopefully this clarifies the issue for you.
Thanks,
Shane
No it is definitely NOT returning the correct datas !!
On hidden link term archive page, I have a list of 12 formations.
Among those 12 formations, 3 are from the parent Etablissement "Université Aube Nouvelle", and 9 are from the Etablissement "School Of Management (SOM)".
So the middle view should only return 12 results, not 100+ like it does now.
Hi Roman,
I spent some time back tracing your archive and the view and what they are displaying.
This archive below is listing out the Parents of the 12 formations that it should display.
hidden link
I'm not sure why this view below will be needed since the Archive will already be listing out the formations.
hidden link
So both the archive and the view are listing out formations. I'm a little confused as to why this view is needed, I might've missed something so further clarification is needed so that I can point you in the right direction.
I understand that you want this view to only list 12 results like the archive but 12 of what.
Looking forward to hearing from you soon.
Thanks,
Shane
Please assign this ticket to another supporter.
Let's go back to where I left off. Your comment here:
https://toolset.com/forums/topic/display-list-of-parent-posts/#post-1676633
You added the current taxonomy archive slug to all the shortcode attributes. That's not what I intended, I suggest you add the current taxonomy archive slug to only the wpvdomaine shortcode attribute. The other Query Filters in the View (not the domaine taxonomy, but the others) should remain set up to respond to URL parameters, and you should remove their corresponding shortcode attributes in this View:
[wpv-view name="liste-des-etablissements-avec-des-formations" view_display="layout" wpvdomaine="[wpv-taxonomy-archive info='slug']"]
This way the other filters continue to respond to the selections made in the front-end filters. This View will ONLY work on the domaine taxonomy archive. Separate Views should be created for each taxonomy archive.
Hello and thank you,
I think I understand now how it should work. Nevertheless, I still can't make it work.
I still got one result per formation, whatever is the slug.
Thank you.
Did you change the logins? I'm not able to find the conexion page, and the login information I have doesn't seem to work at /wp-admin. Private fields are active here.
OK thanks, I made some changes to get us back on track. I removed the front-end filter controls from the "Liste des établissements avec des formations" View for now, since this View should not include any front-end filters. Those filters were causing some incorrect results to display in the Etablissment View. This View should only be used to generate the parent school IDs for a View of Etablissments, using the Query Filters, URL parameters, and shortcode attributes from the WP Archive. I also removed all the unnecessary text from the View's output, I'm not sure why that was added but it was unnecessary for the solution I have been working on. Now with the Formation Initiale filter applied in the Economie archive, only two school IDs are shown in the parent school View: 236 and 197.
hidden link
Based on your comment here, I think those two IDs are correct:
https://toolset.com/forums/topic/display-list-of-parent-posts/#post-1675317
Next, I was suggesting you use these parent Etablissment IDs to create a View that will generate the map markers for each parent Etablissment, as well as a formatted list of parent Etablissments, without all the duplication of posts. Instead, it looks like there is now a map maker shortcode in the View of Formations. This is creating extra map markers, since multiple Formations can have the same parent Etablissment. That's why I was suggesting to use a separate View for this, to prevent duplication of parent Etablissments markers. You can see the extra markers in the console screenshot here.
I think you started this View for that purpose:
hidden link
So I suggest you remove this code from the WP Archive and place the map marker code in the View of Etablissments:
[wpv-map-marker map_id='carte-formations' marker_id='marker-[wpv-post-id item="@formation-etablissement.parent"]' marker_title='[wpv-post-title item="@formation-etablissement.parent"]' marker_field='wpcf-adresse-des-locaux' item="@formation-etablissement.parent"]<p class="infos"> <strong>[wpv-post-link item="@formation-etablissement.parent"]</strong><br> [wpv-view name="nombre-de-formations-pour-cet-etablissement" etablissement="[wpv-post-id item='@formation-etablissement.parent']"]</p> [/wpv-map-marker]
Add any code you want to use to display a list of Etablissment posts in this loop. Then place this View somewhere in the WordPress Archive but NOT inside the wpv-loop tags. I think I need you to take a look now and figure out what to do next.
Hello and thank you very much. All filters now work great.
I needed to duplicate the intermediate view in order to make this work on 4 different archive pages, then added a conditional code like this to choose which one to display:
[wpv-conditional if="( is_post_type_archive('formation', null) eq '1' )"] [wpv-view name="liste-des-etablissements-avec-des-formations-par-niveau"] [/wpv-conditional] [wpv-conditional if="( is_tax('niveau', null) eq '1' )"] [wpv-view name="liste-des-etablissements-avec-des-formations-par-niveau" wpvniveau="[wpv-taxonomy-archive info='slug']"] [/wpv-conditional] [wpv-conditional if="( is_tax('domaine', null) eq '1' )"] [wpv-view name="liste-des-etablissements-avec-des-formations-par-domaine" wpvdomaine="[wpv-taxonomy-archive info='slug']"] [/wpv-conditional] [wpv-conditional if="( is_tax('type', null) eq '1' )"] [wpv-view name="liste-des-etablissements-avec-des-formations-par-type" wpvtypedeformation="[wpv-taxonomy-archive info='slug']"] [/wpv-conditional]
Still, I always have duplicates, since multiple Formations can have the same parent Etablissment, as you mention.
I assume I can improve this thanks to this view in deed, but am not quite sure how to write the code, since those are nested views now. I assume this can work:
[wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau']"]
But I'm pretty sure this one won't:
[wpv-conditional if="( is_tax('niveau', null) eq '1' )"] [wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name="liste-des-etablissements-avec-des-formations-par-niveau" wpvniveau="[wpv-taxonomy-archive info='slug']"]" [/wpv-conditional]
Thank you.
There is a limit to the number of nested shortcode attributes, and you may have reached that limit. I would try it like this first:
[wpv-conditional if="( is_tax('niveau', null) eq '1' )"] [wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[wpv-taxonomy-archive info='slug']']"] [/wpv-conditional]
I would also try it like this:
[wpv-conditional if="( is_tax('niveau', null) eq '1' )"] [wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[wpv-taxonomy-archive info="slug"]']"] [/wpv-conditional]
If neither of these works correctly, you know that you have exceeded the limit for nesting shortcode attributes. One thing I know you could do is use the is_tax conditional to check for each specific term in the taxonomy, then hard-code that term in the shortcode attribute like so:
[wpv-conditional if="( is_tax( 'type', array( 'formation-initiale' ) ) eq '1' )"] [wpv-view name="liste-des-etablissements-avec-des-formations-par-type" wpvtypedeformation="formation-initiale"] [/wpv-conditional]
https://developer.wordpress.org/themes/basics/conditional-tags/#a-taxonomy-page
This is not really practical if you have many terms, because you will have many conditionals. You will have to update the code manually any time a new term is added, so that is not really practical either. To fix this, you could use a custom shortcode that returns the current archive term slug without using any shortcode attributes. I have one from another ticket, with a few modifications:
// https://toolset.com/forums/topic/display-list-of-parent-posts function tssupp_get_current_archive_term_slug( $atts ){ $taxObj = get_queried_object(); $tax = isset($taxObj->taxonomy) ? $taxObj->taxonomy : 0; $slug = isset($taxObj->slug) ? $taxObj->slug : ''; return $slug; } add_shortcode( 'tssupp-get-current-archive-term-slug', 'tssupp_get_current_archive_term_slug' );
Add that code to functions.php or a new custom code snippet , then register tssupp-get-current-archive-term-slug in Toolset > Settings > Front-end Content > 3rd party shortcode attributes. Then you can use it like this:
[wpv-conditional if="( is_tax('niveau', null) eq '1' )"] [wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[tssupp-get-current-archive-term-slug]']"] [/wpv-conditional]
This will fix the problem with maximum nesting level for shortcode attributes.
Hello and thank you,
I'm sorry to say this didn't work neither.
[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[tssupp-get-current-archive-term-slug]']
displays the right results. On this page hidden link "197" (where 197 is in deed the ID for the only Etablissement having a Formation in Domaine "MBA").
But as soon as I nest shortcodes like this
[wpv-view name="infos-sur-cet-etablissement" etablissement="[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[tssupp-get-current-archive-term-slug]']"]
the result is returning the complete list of all Etablissements, and doesn't care anymore about the current term archive page.
Thank you.
I'm trying to work on this, but the WordPress Archive is broken here:
See the screenshot - the server stops sending output without complete content, like a timeout issue. I will try to remove some content from the Loop Editor temporarily to see if I can work around the issue, please stand by.
The topic ‘[Closed] Display list of parent posts’ is closed to new replies.