Reading and the home page precisely home.php

enter image description here
/* ---------------------------------------------- */

/* Setting Post Limits on the HomePage */

/* ---------------------------------------------- */

if ( ! function_exists( 'the_post_limit' ) ) {

    if ( true == get_theme_mod( 'the_post_limit', true ) ) {

        function the_post_limit( $query ) {


            if ( is_admin() || ! $query->is_main_query() )

                return;



            if ( is_home() ) {

                // Display only 1 post for the original blog archive

                $query->set( 'posts_per_page', 8 );

                return;

            }

        }

        add_action( 'pre_get_posts', 'the_post_limit', 1 );

    }

}

The above code is sitting in the theme’s functions.php. The purpose here is to restrict the number of posts on the home page.

The current number here is the number “8”.

Can we somehow produce the number directly from the settings?
I mean whatever number we put there.

Read more here:: Reading and the home page precisely home.php

Leave a Reply

Your email address will not be published. Required fields are marked *