• Resolved RETALI8

    (@aaronviii)


    Hi,
    I am using this custom code to display my recent posts in order to add the HR afterwards. I thought this preferable to using a background image to show a small dividing line in between posts.

    However, draft posts that are still being written are displaying in the list of recent posts, and they can be clicked through to and viewed (even when not logged in).

    This is obviously a problem, can anybody advise what I have done wrong?

    Thanks in advance

    <?php
    	$recent_posts = wp_get_recent_posts();
    	foreach( $recent_posts as $recent ){
    		echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.$recent["post_title"].'" >' .   $recent["post_title"].'</a> <hr class="skinnydivider" /></li> ';
    	}
    ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter RETALI8

    (@aaronviii)

    In case anybody else has this same problem later, I fixed it

    <?php
          $number_recents_posts = 3;
         $args=array('numberposts' => $number_recents_posts,'post_status'=>'publish');
    
          $recent_posts = wp_get_recent_posts( $args );
          foreach($recent_posts as $post){
            echo '<li><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a> <hr class="skinnydivider" /></li> ';
          } ?>

    Thanks, I’m having this same problem right now and your post helped me a lot.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Draft posts showing up in 'recent posts' feed’ is closed to new replies.