Set nopaging for non-logged in users
-
Dear team,
I am trying to set up a restriction to show only 3 posts in the search result page for non-logged in users through the code below.
add_filter( 'relevanssi_modify_wp_query', 'rlv_adjust_search' ); function rlv_adjust_search( $query ) { if ( is_user_logged_in() ) { return $query; } if ( $query->is_search() && !is_admin() && !is_user_logged_in() ) { $query->set( 'nopaging', true ); $query->set( 'posts_per_page', 3 ); $query->set( 'no_found_rows', true ); } return $query; }
It successfully restricted the number of posts. However, the pagination cannot be disabled. I checked the documentation in the website but still cannot find the solution.
Do you happen to have any idea about how to disable the pagination for non-logged in users?
Thank you for your reply in advance.
Best regards,
Lin
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Set nopaging for non-logged in users’ is closed to new replies.