4

I want a page to view only a specific post format (e.g. aside).

Do I have to create my own page and run a custom query, or does Wordpress have an automatic page generated for me (like the categories)?

2 Answers 2

3

Take a look at get_post_format_link()

Here's a little example that uses get_post_format_link() to show a link to the format's archive page. You can see something similar to this in action on Justin Tadlock's site.

function get_post_format_archive_link() {
    return sprintf( 
        '<a class="post-format-archive-link %1$s" href="%2$s">%1$s</a>',
        get_post_format(),
        get_post_format_link( get_post_format() ) 
    );
}

usage:

echo get_post_format_archive_link();

The URL Structure is:

/type/{post format}/

So for an aside we'd have:

http://example.com/type/aside/
2
  • What's the difference between get_post_format_link() & get_post_format_arhive_link()?
    – MegaHit
    Commented Jan 31, 2012 at 5:43
  • @MegaHit get_post_format_archive_link() is just an example that uses the WP core function get_post_format_link(). The output of get_post_format_archive_link() makes styling the individual links easier, but get_post_format_link() does all the real work here. Commented Jan 31, 2012 at 6:36
1

You would need to add theme support for post formats with code.

add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

The code above is what you'd put in your theme's functions.php file, and then in your template files, you would display each post accordingly with the following code, for example if your post format for a post was video:

if ( has_post_format( 'video' )) {
  echo 'this is the video format';
}

See the Codex for more info:

http://codex.wordpress.org/Post_Formats#Adding_Theme_Support

3
  • I already have theme support for the aside post format. What I want now is a page that displays only the posts with the aside post format applied to them. Now, I could create my own page and run a custom query, but I wanted to know if there's a pre-built page for that, similar to how Wordpress automatically creates pages for categories...
    – MegaHit
    Commented Jan 24, 2012 at 5:21
  • Unfortunately no, WordPress does not have that feature included by default. See this page for the official instructions on how to 'use post formats': codex.wordpress.org/Post_Formats#Using_Formats -- Regardless of what you do you would still have to create a template with a query for that post format/list of posts in a post format or modify an existing one.
    – Jared
    Commented Jan 24, 2012 at 5:26
  • Or even more-so, if you were to get the archive link for the post formats, it would fallback and use your archive template, where you would need to edit that file to display posts differently for the post formats.
    – Jared
    Commented Jan 24, 2012 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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