WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope I will make sense, and if you have a better suggestion please let me know. I am just starting WordPress

I want to layout my theme such that I get 3 sticky, not more than 1 month old, or latest posts at the top. Then render the rest of the posts latest 1st below. A picture (below) will explain better I hope. I think I will need custom queries, how might I achieve that

share|improve this question
Do you want advice on how to query for these posts, or on how to layout them, or both? – Jan Fabry Feb 13 '11 at 15:36
@Jan Fabry, I think mainly how to query, but if you were to provide info on both even better. I think for layout it will be mostly CSS? – Jiew Meng Feb 14 '11 at 2:32

If you're familiar with ZF you might be looking for models and layouts, both which you need to manually code with WordPress.

But if you do so, you've got full possibilities.

So feel free to create multiple template files and load them when it's needed (e.g by hooking into template redirect or get_template_part) and then just query what you feel you need for (with WPDB you can fire up any SQL query you need the blog's MySQL server credentials for).

share|improve this answer
Hmm, perhaps you can point me in the right direction, how do most people setup such things? (sticky posts on top). Stickies also cant stay on top forever, how can I implement this? Stickies should also be displaied on index page 1? – Jiew Meng Feb 13 '11 at 12:35
Checkout this nice made structural overview which explains where you can find the template files you might want to tinker with: wordpress theme antanomy --- for querying sticky posts, checkout codex: Sticky Post Parameters and do the loop. – hakre Feb 13 '11 at 15:30

For the query, I would take a look at how WordPress currently includes sticky posts in the loop. It does a regular query, and then gets the sticky posts in a separate query. If any of the sticky posts exist in the regular query, it is taken out and put at the top. The remaining sticky posts are then also put at the top.

What you should do is query the latest posts, but ignore sticky posts. Then, you query the sticky posts that are less then one month old, ordered by publication date, with a limit of 3. If this results in any posts, you also go through your regular posts to remove any post if it already is one of your sticky posts.

You can prevent the regular query from returning sticky posts by setting the caller_get_posts option (or ignore_sticky_posts, as this is called in WP 3.1. The first option was added when sticky posts were added to indicate that the query came from get_posts(), and thus should ignore sticky posts). To get the sticky posts, you read the post IDs from get_option( 'sticky_posts' ).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.