Site logo

Archived topic

posts per page in blog archive

3 replies · Started by Srini on August 3, 2022

Viewing posts 1–4 of 4

Hi

Blog archive is shoeing 3 posts only in the page, how to change the posts per page?

Hi Srini,

The setting for that can be found in Settings > Reading.

Thank you, Fernando.

How can I show specific category posts only in the blog archive page?

Try this snippet:

function set_main_query_categories( $query ) {
    if ( ! is_admin() && $query->is_home() && $query->is_main_query() ) {
		$query->set( 'tax_query', array(
            array(
                'taxonomy' => 'category',
                'field' => 'slug',
                'terms' => array(‘category-slug’),
            ) ) );
		
    }
}
add_action( 'pre_get_posts', 'set_main_query_categories' );

Replace category-slug with your category’s slug name.

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

This archived topic is closed to new replies.