SHARE
TWEET

WP Add Recent Sticky Posts

ridgey28 Dec 13th, 2016 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php /* Add option to filter WordPress sticky posts only in:  [url] http://www.worldoweb.co.uk/2012/display-your-wordpress-recent-posts-on-a-static-page
  2. */
  3.  
  4.  
  5. $args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
  6. $postslist = get_posts( $args );
  7. echo '<ul id="latest_posts">';
  8.  foreach ($postslist as $post) :  setup_postdata($post); ?>
  9.   <?php if (is_sticky()){?>
  10.     <li><strong><?php the_date(); ?></strong><br />
  11.     <a href="<?php the_permalink(); ?>" title="<?php the_title();?>"> <?php the_title(); ?></a>
  12. </li>
  13. <?php } endforeach; //end if_sticky() and foreach()?>
  14.  </ul>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top