elegant themes

How to create a yearly archive for a category with custom fields in WordPress

| October 23, 2013 | 1 Comment

One of our clients has a category of special research papers that needs to display the number of the paper next to the title of the paper. In order to style this research paper’s number differently than the title, we created a custom field using the Types plugin.

Silly girl, you don’t need a plugin to create a custom field.

True, true. BUT. The Types plugin is quite lovable since it also creates a meta box that can be a WYSIWYG, checkboxes, numeric, single line text, multi-line text, and a whole bunch of other options. which is super handy and much more user-friendly for our client.

Here’s a screenshot of the custom field meta box that I created with the Types plugin:


The client wanted to display this category of special research papers in an archive that divided the papers(posts) by year, and under each year, the title of the post, including the custom field.

Here’s the structure:

Our Special Research Papers 


  • Paper No. 6 (custom field) | My Fabulous Title (post title)
  • Paper No. 5 (custom field) | My Fabulous Title (post title)
  • Paper No. 4 (custom field) | My Fabulous Title (post title)


  • Paper No. 3 (custom field) | My Fabulous Title (post title)
  • Paper No. 2 (custom field) | My Fabulous Title (post title)
  • Paper No. 1 (custom field) | My Fabulous Title (post title)

And here’s a screenshot of the archive on the site:


Our solution is a bit hack-y but it works! Here’s what we did:

  1. Install and activate the Types plugin
  2. In the plugin settings, click “Create a Custom Field”
  3. Set up the custom field with a title, and the type of custom field (numeric, wysiwyg, etc. ). Make sure to get the id of the custom field you created.  (ex. special-papers)
  4. Create a new page template like papers-template.php and insert this code:

That’s it!

Tags: , , , , ,

Category: Code Snippets

About Rebecca Markowitz: Rebecca Markowitz has built over 50 WordPress sites for clients as Web Project Manager and WordPress specialist at illuminea. illuminea is a Jerusalem-based boutique web agency. WPGarage shows my dedicated relationship with WordPress over the years - full of love, laughs, tears, growth and strong drinks. L'chaim! View author profile.

Comments (1)

Trackback URL | Comments RSS Feed

  1. […] How To Create a Yearly Archive for a Category with Custom Fields in WordPress […]

Leave a Reply

If you want a picture to show with your comment, go get a Gravatar.

More in Code Snippets (4 of 36 articles)