• How can I make this code to show only 4 latest posts?

    <?php while($featured_posts->have_posts()): $featured_posts->the_post(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • put this code above your loop
    $featured_posts = array(‘post_type’=>’your post type name’,’posts_per_page’=>4);

    Thread Starter arska2

    (@arska2)

    I have this kind of code:

    <?php while($featured_posts->have_posts()): $featured_posts->the_post(); ?>
    <div id="htmlcaption_<?php echo $post->ID; ?>" class="slider-text nivo-html-caption">
    
    <span class="date"><?php the_time('F d, Y'); ?></span>
    
    <div class="slider-heading">
    
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <p><?php echo string_limit_words(get_the_excerpt(), 40); ?></p>
    
    					</div>

    Where should I put the code?
    And what is my post type name?

    sorry for my noobness

    you can set posts per page from your dashboard also
    from settings->reading->posts per page

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show only 4 latest posts?’ is closed to new replies.