I am trying to get the parametric search working with nested custom post types. I tried to follow the instructions as mentioned in here: https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/ But it doesn't work correctly.
Let me explain: I have a custom post type "wettbewerbe" (parent). Each of the parent relates to one child "auslobungen". I created a few with parametric search for the taxonomy "verfahrensart" for the parent "wettbewerbe". And a view for the child "auslobungen", in which I chose the query filter "post set by parent view".
I want to show the parametric search on the childrens archive page. So I created an wordpress-archive-view for "auslobungen" in which i filled in the parent-view with the parametric search:
<wpv-loop>[wpv-view name="auslobungen-archiv-filter"]</wpv-loop>
Now the children-archive shows all my "wettbewerbe" with related "child fields". As I planned to. But when I filter the archive by the taxonomy "Verfahrensart", only the parent custom post type is showing up, without the related child fields. I found out, that when I'm checking a taxonomy, it adds a parameter "&wpv_post_id=23" to my url. And this is causing the problem. If I delete this parameter, the child fields are displaying correctly.
What did I do wrong? Please for help!
Dear diana,
The normal view does not work as expected in the archive page, in your case, you can remove the URL parameter "wpv_post_id" with Views filter hook "wpv_filter_requires_current_page":
For example, add below codes into your theme/functions.php
add_filter('wpv_filter_requires_current_page', 'remove_urlpara_func', 99, 2);
function remove_urlpara_func($requires_current_page, $view_settings){
if($view_settings['view_id'] == 123){
return false;
}
return $requires_current_page;
}
Please replace 123 with the problem View's ID, and test again.
Thanks Luoy,
I tried it out, but the wpv_post_id is still a parameter in my URL.
I tested it by replacing your View-ID with the ID
* from my archive-view
* from my parent-view with parametric search
* from my childrens view
* and by given all three IDs as ID
Still not working. The URL-Output doesn't change. Still the same:
<em><u>hidden link</u></em>
Sorry, there is a mistake in my codes, please try to modify it as below:
add_filter('wpv_filter_requires_current_page', 'remove_urlpara_func', 99, 2);
function remove_urlpara_func($requires_current_page, $view_settings){
global $WP_Views;
if($WP_Views->current_view == 123){
return false;
}
return $requires_current_page;
}
Please replace 123 with the problem View's ID, and test again.
Thanks Luoy,
that did the trick! Worked out for me.
For the future: Did I something wrong with setting up the parametric search?
If yes, how can I do better?
Or is that a bug?
Thanks again! Diana