WordPress Code Snippets

A fresh mix of code snippets and tutorials

Post format archives


The Post Format Archives Widget makes it easy to link to your custom-formatted posts. Here is a snippet for conditionally displaying their respective archives.

So let’s say that you’re displaying links to the archive-views of your various custom-formatted posts (i.e., Post Formats). When visitors follow those links, the Post Format archives will be displayed via your theme’s archive.php template (or index.php, depending on the theme). To customize each of the different Post Format archive-views, add the following snippet in archive.php (or similar):

Some notes about this code:

  • It assumes the default WP Post Formats, edit to match your own.
  • It should be included in the Loop, after if (have_posts()) and before while (have_posts()).
  • The code for the Date Archives can be removed if not needed.
  • Edit the markup and customize the PHP to suit your design.


Here is an example of this technique implemented in the archive.php Loop:

As you can see, this snippet goes beyond Post Format archives and provides custom output for just about every type of WordPress archive. You’ve got your Post Formats, Dates, Tags, Categories, and the whole gang. By editing the markup to suit your needs, this Loop template facilitates granular control over your various archive-views.

Cheers people.

Learn more

WordPress Themes In Depth

Show Support

Like our new Facebook Page to show support!