• swmaher

    (@swmaher)


    I created custom code to show recent published posts. Unfortunately, the loop also shows scheduled posts that are not live, thus causing repeated 404 errors. How do I only show currently live posts?

    <?php
          $recent_posts = wp_get_recent_posts(3);
          foreach($recent_posts as $post){
            echo '<li><img width="16px" height="16px" src="https://www.site.com/wp-content/uploads/2010/12/arrow.png"><a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a> </li> ';
          } ?>
  • The topic ‘Only show Published posts for recent posts, removed scheduled posts.’ is closed to new replies.