Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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)?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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/
share|improve this answer
    
What's the difference between get_post_format_link() & get_post_format_arhive_link()? –  MegaHit Jan 31 '12 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. –  goto10 Jan 31 '12 at 6:36
add comment

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

share|improve this answer
    
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 Jan 24 '12 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 Jan 24 '12 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 Jan 24 '12 at 6:33
add comment

Your Answer

 
discard

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.