Results 1 to 2 of 2

Thread: How to limit posts per page

  1. #1
    Thread Starter
    Amateur
    Not a Verified Customer
    Pisos-Alquiler.com's Avatar
    Join Date
    Mar 2010
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to limit posts per page

    The code example is for showing 2 posts per page when any Category an search archive page is being displayed.

    Choose and add the following lines to your Classipress functions.php file:

    Code:
    function limit_posts_per_archive_page() {
    	if ( is_category() )
    		$limit = 2;
    	elseif ( is_search() )
    		$limit = 2;
    	else
    		$limit = get_option('posts_per_page');
    
    	set_query_var('posts_per_archive_page', $limit);
    }
    add_filter('pre_get_posts', 'limit_posts_per_archive_page');
    Regards!

  2. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    40,967
    Thanks
    169
    Thanked 3,406 Times in 3,277 Posts

    Re: How to limit posts per page

    Thanks for sharing.
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)