• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Change Number of Posts On 1st Page of Paginated Homepage Archive Only

This PHP code sets the post per page only on the first page of the home page archive.

All other paginated pages like page 2,3,4 and so on will display the number of posts set in the Reading settings native to WordPress.

Using a code editor and FTP, simply copy and paste the following code to the end of your child themes functions file.

Register for full access

Reader Interactions

Comments

  1. Rita says

    August 29, 2017 at 8:17 am

    Thank’s for a very fast answer 🙂

    Log in to Reply
    • Rita says

      August 29, 2017 at 8:29 am

      Another question. How do the search question sort the search result. It doesn’t seem to be in date order?

      Log in to Reply
      • Brad Dalton says

        August 29, 2017 at 8:38 am

        Log in to Reply
        • Rita says

          August 29, 2017 at 11:09 am

          Thank you

          Log in to Reply
  2. Rita says

    August 22, 2017 at 4:47 pm

    I got a code from you. Do not know in which tutorial. It helped me to increase the number of posts on the category pages. I wonder if it could be altered so that it changes the number of posts on all archive pages – that is category, date and tag – but NOT on the home page. Or perhaps a code per archivetype?
    This is the code I got from you:

    /* Change the number of recipe items to be displayed 
    add_action( 'pre_get_posts', 'wpsites_category_limit_posts' );
    function wpsites_category_limit_posts( $query ) {
    
    	if( $query->is_main_query() && !is_admin() && is_date() ) {
    		$query->set( 'posts_per_page', '20' );
    	}
    
    }

    Something completely different: The notify me of follow-up comments by email on this page doesn’t seem to function for me.

    Log in to Reply
    • Brad Dalton says

      August 22, 2017 at 4:59 pm

      Add this code to your functions file and change the 1

      Log in to Reply
      • Rita says

        August 23, 2017 at 1:38 am

        Great! Thanks!

        Log in to Reply
        • Rita says

          August 29, 2017 at 7:49 am

          How would I write the same thing if I want a different number on the search page? Tried to change is_archive to is_search but that didn’t do it.

          Log in to Reply
          • Brad Dalton says

            August 29, 2017 at 7:54 am

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags