Home › Toolset Professional Support › [Waiting for user feedback] 1st search results page empty or only with recent results
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 1 voice.
Last updated by Christopher Amirian 16 hours, 59 minutes ago.
Assisted by: Christopher Amirian.
Hi Support
Yesterday we moved to a new host, and also installed the latest Toolset plugins (I think it was Blocks and Maps), so not sure which could be an issue.
We have a normal Toolset search page, which was all working fine on the old host and before the latest plugin update:
hidden link
Currently the 1st page of results is either blank or only showing very recent results (ie nannies who recently registered with us). We have no such restriction on the query. The first page should show 10 results, but currently only showing 2 results. This morning page 1 showed no results, but results continued on page 2.
It looks like a caching issue for me, however have set the page to not be cached by WP Rocket, and also disabled the Redis cache plugin.
After disabling caching on the page, I cleared the WP Rocket Cache just to be sure and "flushed" the Redis cache.
Any ideas what is happening here?
Thanks and kind regards
Simon
Hi Simon,
I suggest that you do the tests below:
Toolset/View caching after the update
A cached first-page dataset can mismatch the current filters.
Do this:
Toolset → Settings → Front-end content → click Clear cache.
Edit the View → in Pagination & Settings, temporarily disable “Cache results of this View” (if enabled), save, retest.
Pagination parameter clash
If the View uses the default URL parameter page, it can conflict with the WordPress page’s own pagination variable—especially on multilingual URLs—so page 1 may behave oddly.
Fix (Legacy Views):
View → Pagination and Slug → change the “Pagination page parameter” from page to something unique, e.g. nnpg.
Fix (Blocks View):
Select the View block → Pagination panel → URL parameter name → set nnpg.
Update the page, retest page 1.
Recreate the View
Create a new view and do not copy anything from the old view and use normal setup guides and see if it fixes the issue.
Thanks.
Hi Christopher
I think I've ascertained what is actually happening. The items in the View Search Nanny Ads from CPT nanny-ad.
When these Nanny Ads are created (on the front end by users), they have a Boolean flag on the field nanny-visible-for-families set to 0 by default, as the Nanny User that created them has not yet been verified.
When the User has been verified, my colleague changes the user's role from 'unverified_nanny' to 'native_nanny' (ie a fully qualified, verified nanny). Also she updates the field nanny-visible-for-families from 0 to 1 in the Nanny Ad, so that it would appear in the View "Find a Native Nanny Search and Results View".
Yesterday, as she verified the nannies and updated the nanny-ad fields from 0 to 1, the ads began to appear in the search.
Ideally, we would like a cleaner solution where the we could filter the View "Find a Native Nanny Search and Results View" by post author's role, so that the View could only show Nanny Ads (CPT nanny-ad) from users with role 'native_nanny'. We still need to retain the Boolean flag field nanny-visible-for-families so that Nannies can choose whether to hide their ads or not.
When I add a filter and choose post author, I cannot see a way to filter on the author's role. I checked here too:
https://toolset.com/documentation/legacy-features/views-plugin/filtering-views-query-by-author/
I had tried initially to do this within the Content Template itself with the code:
[wpv-conditional if="( '[user_role_func]' eq 'native_nanny' )"] ... [/wpv-conditional]
Perhaps it is not the cleanest way to do it. Is there a better way so we don't have these "gaps" or blank pages in the Search Results?
Kind regards
Simon
Hi Simon,
First of all sorry for the late reply.
It seems to be hard to do this only via UI. I did not try this method, but I thought, what if you add an author-role filter via a small hook.
Try the code below using the Toolset custom code UI:
add_filter( 'wpv_filter_query', function( $query_args, $view_settings, $view_id ) {
// Target by View slug (preferred) OR by numeric ID.
$target_view_slugs = array( 'find-a-native-nanny-view' ); // <-- replace with your View's slug
$is_target = ( isset( $view_settings['view_slug'] ) && in_array( $view_settings['view_slug'], $target_view_slugs, true ) )
|| (int) $view_id === 0; // optionally replace 0 with your View ID
if ( ! $is_target ) {
return $query_args;
}
// Get all user IDs that have the role `native_nanny`.
$author_ids = get_users( array(
'role' => 'native_nanny',
'fields' => 'ID',
) );
// If no authors match, force an empty result in a cheap way.
if ( empty( $author_ids ) ) {
$query_args['post__in'] = array( 0 );
return $query_args;
}
// Constrain the View to those authors.
$query_args['author__in'] = $author_ids;
return $query_args;
}, 10, 3 );
Keep your existing meta filter nanny-visible-for-families = 1 in the View. The hook simply adds author__in on top.
If you also want to include another role later (e.g., premium_nanny), change to:
$author_ids = get_users( array(
'role__in' => array( 'native_nanny', 'premium_nanny' ),
'fields' => 'ID',
) );
After adding the hook: Toolset → Settings → Front-end content → Clear cache, then clear any page/server cache and retest page 1.
I think this approach should eliminate the “gaps/blank first page” because WordPress paginates after all constraints (role + meta) are applied.
Just to rephrase, I did nto test that myself but that was what I could think of.
Thanks.
Hi Christopher
Thanks for this. I still have to try it. I can only get to this tomorrow. Will keep you posted on how it goes!
Kind regards
Simon
Hi Simon,
Thanks.