• Resolved Pankaj Jangir

    (@pankajjangir)


    Hello,

    I want to use below code for home page to show only blog category posts:

    <?php
    function generate_home_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'category_name', 'blog' );
        }
    }
    add_action( 'pre_get_posts', 'generate_home_category' );
    ?>

    How do I do that?

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP code for home page’ is closed to new replies.