Skip Navigation

[Waiting for user confirmation] 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 15 replies, has 1 voice.

Last updated by Minesh 1 day ago.

Assisted by: Minesh.

Author
Posts
#2829281
Screenshot 2025-10-15 at 13.17.14.jpg

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

#2829297

Christopher Amirian
Supporter

Languages: English (English )

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.

#2829437
Screenshot 2025-10-16 at 13.52.34.png

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

#2830287

Christopher Amirian
Supporter

Languages: English (English )

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:

https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/


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.

#2830451

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

#2831165

Christopher Amirian
Supporter

Languages: English (English )

Hi Simon,

Thanks.

#2831795

Hi Chrisopher

I was kind holding back here too becuase I don't want to come into conflict with any changes you might be making from the other ticket. The other ticket has much higher priority because Location is the most important search critieria for our users.

Is it possible to set this ticket so it doesn't auto-close until the other ticket you're working on is resolved?

Would be great!

Thanks and regards
Simon

#2832866

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Would you mind to move ahead and test this on the dev site you have?

#2832976

I didn't want to come into conflict with you in case you are testing something, as we would be working in the same objects.

Kind regards
Simon

#2833377

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - as we done with another ticket, you may proceed here and mark resolve when you can.

#2833435

Hi Minesh

If you want to continue to work on Find a Job rather than Find a Native Nanny, I can proceed here (I can only get to this tomorrow).

That way, we can continue to work on both tickets simultaneously.

Thanks and kind regards
Simon

#2833597

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - I will check and work on "Find a job".

#2834365

Hi Minesh

Using Christopher's suggested code as a template I added the Custom Code snippet:

filter-find-a-native-nanny-view-by-postauthor.php

All I changed was the View slug, and changed 'role' => 'native_nanny' to 'role__in' => ['native_nanny']

On querying the view, (Find a Native Nanny Search and Results View), initially I had 11 results, as expected, 10 from nanny Siobhan and 1 from nanny Sabine.

When I change nanny Siobahn (nativenanny2@hotmail.com) to role "Unverified Nanny" (unverified_nanny) and requery, I'm getting zero results. But when I set her role back to "Native Nanny" (native_nanny), I get 11 results, 10 from her, and 1 from Sabine (nativenanny4@gmail.com).

I would expect to see the Nanny Ad from Sabine, even when Siobhan is set to role unverified_nanny.

So I don't think the query filter is working correctly...

Thanks and regards
Simon

#2834375

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What if you change the role__in argument to as follows to search in two roles "native_nanny" and "unverified_nanny" and save your code snippet and check if that help you to get the correct results.

'role__in' => array( 'native_nanny', 'unverified_nanny'),
#2834450

Hi Minesh

The goal is to only filter out all Nanny Ads whose post_author's role is not native_nanny.

So the correct results would be 1, if I change Siobhan's role to Unverified Nanny, however it is showing 0.

Kind regards
Simon