Skip Navigation

[Resolved] Designing one view with “breaks” or two views using same Query Filter

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

Problem:

How can two views, both on the same page, both use the same query filter with same URL parameter?

Solution:

Yes, it is possible to pass same URL parameter to both views, and take effect on both of them, you can disable AJAX search, for example:

Edit both post views:

1) in section "Custom Search Settings", enable option: Full page refresh when visitors click on the search button,

2) In section "Search and Pagination", add a submit button

Relevant Documentation:

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.

This topic contains 5 replies, has 2 voices.

Last updated by DavidW2160 1 year, 4 months ago.

Assigned support staff: Luo Yang.

Author
Posts
#1722229

I have a custom post type with two categories -- "premium" and "basic". I want to display premium posts first, then basic posts. There are two logical ways to do this:
1) Sort on category descending ... When the first premium post is detected: print "Premium", then display the "Premium' posts; then, when the first basic post is detected: print "Basic" and then display the "Basic" posts
2) Using two views, one for Premium and one for Basic. Display the Query filter for the Premium view, but use the same query for the Basic view -- that is, the basic view would display only the search results. Other than selecting on category, the views are currently identical.
How?

#1722257

Using 2 views (#2 in my original post)
It might be helpful to know the URL of the search string. I have one Premium post with a value of "Eugene" and one Basic post with a value of "Cottage Grove".

This query string, output from the Premium view, shows both Premium and Basic posts -- that is, it doesn't filter the Basic view at all
?wpv_post_search=Eugene&wpv_aux_current_post_id=222&wpv_aux_parent_post_id=222&wpv_view_count=565

This query string shows just the Premium post, as it should:
?wpv_post_search=Eugene

This query string shows just the Basic post, as it should:
?wpv_post_search=Cottage

The abbreviated query string is what I want, since the rest of it mucks up the results. Is there any way to suppress everything after the search criteria? (i.e. suppress this: &wpv_aux_current_post_id=222&wpv_aux_parent_post_id=222&wpv_view_count=565) I don't even understand what the rest of the query string is supposed to do.

#1722509

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hello,

In your case, I suggest try the Using 2 views (#2 in your original post).

There isn't such kind of built-in feature to suppress those URL parameters, they are required for Views ajax pagination/search features.

In your case, the URL parameter "wpv_aux_current_post_id" and "wpv_aux_parent_post_id" should be current page ID.
"wpv_view_count" should be view's ID

#1727495

I may not have been clear -- I have two queries on one page, and want the query filter to be used by both views. In a nutshell, my question is really this: how can two views, both on the same page, both use the same query filter?

#1727851

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Yes, it is possible to pass same URL parameter to both views, and take effect on both of them, you can disable AJAX search, for example:
Edit both post views:
1) in section "Custom Search Settings", enable option: Full page refresh when visitors click on the search button,
2) In section "Search and Pagination", add a submit button

Then test again

#1728409

My issue is resolved now. Thank you!