Skip Navigation

[Closed] Display list of parent posts

This support ticket is created 4 years, 6 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
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)

Author
Posts
#1707215
extra-markup.png

Okay I see why the page was breaking. I was not closing the custom shortcode explicitly. Both the opening and closing tags should be used, especially in conditionals and nested shortcode attributes:

[tssupp-get-current-archive-term-slug][/tssupp-get-current-archive-term-slug]

You mentioned the Infos View was not filtering correctly with the custom shortcode used to filter the Etablissement View:

[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][/tssupp-get-current-archive-term']"]

There was a problem in the output of this View:

[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[tssupp-get-current-archive-term-slug][/tssupp-get-current-archive-term-slug]']

Even though the output looked correct on the front-end of the site, I could see a problem when I inspected the DOM using the browser inspector. Screenshot attached. On the front-end the output looked like this:

197,

In the inspector, I could also see a map marker shortcode and other markup, which was not displayed on the front-end. This extra code was being passed into the etablissement shortcode attribute, and that was breaking the Query Filter. I removed the map marker shortcode, other extra markup and spaces from the loop of this View:
hidden link

Here is some map marker code I removed, in case you need to place it somewhere else:

[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]

Then I removed all my testing code leftover in the WP Archive. Now you can see the results here: hidden link

Here is the strange thing: I must include the View twice on the page. I'm not sure exactly why this is happening. Check it out, this code works fine:

[wpv-conditional if="( is_tax('niveau', null) eq '1' )"]
  <div style="display:none;">[wpv-view name='liste-des-etablissements-avec-des-formations-par-niveau' wpvniveau='[tssupp-get-current-archive-term-slug][/tssupp-get-current-archive-term-slug]' cached='off']</div>
  [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][/tssupp-get-current-archive-term-slug]' cached='off']" cached="off"]
[/wpv-conditional]

But if I remove the first hidden view, it breaks the filter again:

[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][/tssupp-get-current-archive-term-slug]' cached='off']" cached="off"]
[/wpv-conditional]

This is completely bizarre. Any idea what might be happening here? Is there any custom PHP in place for this View, or this WP Archive? The only thing I can think of is this: https://toolset.com/errata/shortcodes-in-conditionally-displayed-content-may-not-be-executed-on-the-front-end/
Can you try to disable pcre.jit by adding this code to your wp-config.php file:

ini_set('pcre.jit', false);
#1707951

It works now ! Thank you very much !

Now indeed it would be great to have a "cleaner" code.

I added the "ini_set('pcre.jit', false);" code to my wp_config and tried to delete the display:none views without success.
Also I don't think there is any other php custom code for this page. Anyway, all custom php are on functions.php for now on.

Last, I wonder what's the use of "cached=off" ? Is it for development purpose ? Or should I keep this in the code after debugging is successful ?

Thank you.

#1708119

Last, I wonder what's the use of "cached=off" ? Is it for development purpose ?
Yes it was for debugging purposes, you can remove it.

#1708789

Thank you for the great support. My issue is resolved now. Thank you!
Could you please open escalate this to second tier in order to find out what could be the problem with the need of double views ?
Many thanks for great support.

#1709309

Could you please open escalate this to second tier in order to find out what could be the problem with the need of double views ?
We can escalate but this archive is a bit too complex right now to effectively debug it. If you want to escalate, please create a similar archive with no conditionals in the filters or the loop editor. This new archive should be specifically for one term in one taxonomy, for example "MBA" in the "niveau" taxonomy. Remove all the extra text and other content from the filters and loop. Remove all the custom CSS and custom JavaScript. Then we can use some custom code to apply this archive only to the MBA term archive, so it is not displayed anywhere else on the rest of the site, and you can continue working on the other archive while we test this one:

add_filter( 'wpv_filter_force_wordpress_archive', 'test_simple_archive_mba', 30, 2 );
function test_simple_archive_mba( $wpa_assigned, $wpa_loop ) {
  $wpa_to_apply = $wpa_assigned;
  $current_taxonomy = isset(get_queried_object()->taxonomy) ? get_queried_object()->taxonomy : null;
  $term_id = isset(get_queried_object()->term_id) ? get_queried_object()->term_id : null;
  // only for niveau taxonomy, only for mba term (64)
  if( !$current_taxonomy || $current_taxonomy != 'niveau' || !$term_id || $term_id != 64 )
    return $wpa_to_apply;

  $wpa_to_apply = 999;

  return $wpa_to_apply;
}

Replace 999 with the numeric ID of the new WordPress Archive. Then /niveau/mba should show this new simplified WordPress Archive and we can test it more effectively. If the problem remains in the simpler archive, I can ask the 2nd tier to investigate further.

The topic ‘[Closed] Display list of parent posts’ is closed to new replies.