Display posts for a single post format

The post format taxonomy:

The post format is a default taxonomy, registered with:

register_taxonomy( 'post_format', 'post', array(
            'public' => true,
            'hierarchical' => false,
            'labels' => array(
                    'name' => _x( 'Format', 'post format' ),
                    'singular_name' => _x( 'Format', 'post format' ),
            ),
            'query_var' => true,
            'rewrite' => $rewrite['post_format'],
            'show_ui' => false,
            '_builtin' => true,
            'show_in_nav_menus' => current_theme_supports( 'post-formats' ),
    ) );

where

$rewrite['post_format'] = $post_format_base ? array( 'slug' => $post_format_base ):false;

and

$post_format_base = apply_filters( 'post_format_rewrite_base', 'type' );

Note that the taxonomy slug is post_format and the rewrite slug is type.

The post format terms:

We can see the available post formats from the get_post_format_strings() function:

/**
 * Returns an array of post format slugs to their translated and pretty display versions
 * 
 * @since 3.1.0
 *
 * @return array The array of translated post format names.
 */
function get_post_format_strings() {
        $strings = array(
                'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard
                'aside'    => _x( 'Aside',    'Post format' ),
                'chat'     => _x( 'Chat',     'Post format' ),
                'gallery'  => _x( 'Gallery',  'Post format' ),
                'link'     => _x( 'Link',     'Post format' ),
                'image'    => _x( 'Image',    'Post format' ),
                'quote'    => _x( 'Quote',    'Post format' ),
                'status'   => _x( 'Status',   'Post format' ),
                'video'    => _x( 'Video',    'Post format' ),   
                'audio'    => _x( 'Audio',    'Post format' ),
        );
        return $strings;
}

The terms have the slug post-format-{$format} where $format can be one of:

aside, chat, gallery, link, image, quote, status, video, audio

where standard is not included.

The post format rewrite rules:

Here you can see the corresponding generated rewrite rules:

Rewrite Rules

according to the Monkeyman Rewrite Analyzer.

The post format public queries:

We can therefore use the following public queries:

http://example.tld/type/post-format-aside/
http://example.tld/type/post-format-chat/
http://example.tld/type/post-format-gallery/
http://example.tld/type/post-format-link/
http://example.tld/type/post-format-image/
http://example.tld/type/post-format-quote/
http://example.tld/type/post-format-status/
http://example.tld/type/post-format-video/
http://example.tld/type/post-format-audio/

to display all posts in a given post format.

Update:

@ToddBenrud said he managed to get:

http://example.tld/type/image/

to work.

The reason for that is the following request filter:

/**
 * Filters the request to allow for the format prefix.
 *
 * @access private
 * @since 3.1.0
 */
function _post_format_request( $qvs ) {
        if ( ! isset( $qvs['post_format'] ) )
                return $qvs;
        $slugs = get_post_format_slugs();
        if ( isset( $slugs[ $qvs['post_format'] ] ) )
                $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ];
        $tax = get_taxonomy( 'post_format' );
        if ( ! is_admin() )
                $qvs['post_type'] = $tax->object_type;
        return $qvs;
}
add_filter( 'request', '_post_format_request' );

This means that a request with the query variable:

Array
(
    [post_format] => image
)

is modified to the correct term name:

Array
(
    [post_format] => post-format-image
    [post_type] => Array
        (
            [0] => post
        )
)

So we could also use:

http://example.tld/type/aside/
http://example.tld/type/chat/
http://example.tld/type/gallery/
http://example.tld/type/link/
http://example.tld/type/image/
http://example.tld/type/quote/
http://example.tld/type/status/
http://example.tld/type/video/
http://example.tld/type/audio/

Leave a Comment