Skip Navigation

[Resolved] Parametric search in nested fews doesn't show child fields

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

Problem:
Remove wpv_post_id URL parameter from Views filter form.
Solution:
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){
    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.
Relevant Documentation:

This support ticket is created 8 years, 1 month 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by dianaM-4 8 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#371926

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!

#372028

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.

#372093

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>
#372422

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.

#372486

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

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