• 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)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi isn’t responsible for the paging, and ignores the nopaging parameter. Also, setting nopaging and posts_per_page together doesn’t probably work as expected, as using nopaging is essentially the same as setting posts_per_page to -1.

    Pagination is controlled by your theme. Can you add the is_user_logged_in() check around the paging in your theme templates?

Viewing 1 replies (of 1 total)
  • The topic ‘Set nopaging for non-logged in users’ is closed to new replies.