WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display Specific category and number of post (2 posts)

  1. Shovan Sargunam
    Member
    Posted 1 year ago #

    Hi,

    Currently I have blogs page which pulls content from these category - blog, news and video.

    <?php $recent = new WP_Query(); ?>
    <?php $recent->query('cat=4,cat=15,cat=159'); ?>
    
    <?php while($recent->have_posts()) : $recent->the_post(); ?>
    	<div class="row <?php if ( $post->ID == $wp_query->post->ID ) { echo ' first-post yellow-higlight'; } else {} ?> blog-post">

    I would like to limit number of post shown on that page to 5.

    I believe the code I have written need to be modified or updated.

    Any suggestion would help

  2. Shovan Sargunam
    Member
    Posted 1 year ago #

    I found it

    <?php
     $catPost = query_posts( 'cat=4,15,159&posts_per_page=5' ); //change this
       foreach ($catPost as $post) : setup_postdata($post); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic