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

How do I create a page template were I can query all the posts from the Custom Post Type - let's say - "project" and order the results by year, displaying the year value at the beginning of each group .

share|improve this question
You should probably first look into templates and WP_Query, then try to narrow your question down a little. This is fairly broad. Also, search the site, there is at least one recent thread about displaying items with "year" headers. – s_ha_dum Dec 11 '12 at 16:29
I resolved the question using the Custom Post Type Archives plugin (wordpress.org/extend/plugins/custom-post-type-archives/faq) and this article: alex.leonard.ie/2009/08/27/… Thank you – baalstorm Dec 16 '12 at 16:41

You don't need to create a page template to list the project post type, just go to /project/ and you'll have a full date ordered listing.

The template powering that page will be determined as follows:

  • archive-project.php
  • archive.php
  • index.php

So create an archive-project.php in your theme. Using this you can specify to list only the titles.

Finally, on each post check to see if the year of the data has changed, and if so, echo the year out with whichever markup you please, and continue as usual, making note to echo the year out on the first project post.

share|improve this answer
Sounds like the right way! thanks, i'll try that out :) – baalstorm Dec 13 '12 at 16:10

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.