List Your Scheduled Posts


The problem. Like many bloggers, you probably want your readers to visit your blog more often or subscribe to your RSS feed. A good way to make them curious about your future posts is by listing the titles of your scheduled posts.

The solution. Open any of your theme files and paste the following code:

1 <?php
2 $my_query = new WP_Query('post_status=future&order=DESC&showposts=5');
3 if ($my_query->have_posts()) {
4 while ($my_query->have_posts()) : $my_query->the_post(); ?>
5 <li><?php the_title(); ?></li>
6 <?php endwhile;
7 }
8 ?>

Code explanation. In this code, we have created a custom WordPress query using the WP_Query class to send a database query and fetch the five most recent scheduled posts. Once done, we use a simple WordPress loop to display the posts’ titles.

Sources:

Hot Trending Topics

  1. Avoid Duplicate Posts in Multiple Loops
  2. Create a “Send to Twitter” Button
  3. Automatically Get Images on Post Content
  4. Display recent post from specific category (WordPress Trick)
  5. 8 Useful WordPress SQL Hacks

Check These Out!!

Comments