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 would like to know what template wordpress uses to display post formats archive pages? What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates? Also is there a way to know if loaded page is post formats archive page?

share|improve this question
    
Sorry @s_ha_dum, they are taxonomy terms. And they have archive just like any other taxonomy term. –  G. M. Sep 3 '13 at 1:51
    
You are right @G-M, and I dislike WordPress a little bit more. Thanks for the correction. –  s_ha_dum Sep 3 '13 at 2:44
    
@s_ha_dum Wordpress is just as a girlfriend. While you are still knowing her you are full of love, when you know better love start becoming less and when you alredy know every detail (and every fault) love is just ended. :) –  G. M. Sep 3 '13 at 5:15

2 Answers 2

Post formats are used to customize posts according to their "meta" content, but they are always posts and as posts they will be listed on archive and category pages.

What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates?

Please take a look at WordPress Codex - Template Hierarchy section.

I would like to know what template wordpress uses to display post formats archive pages?

An archive ( posts by year, month, day ) page, normally runs over archive.php template. A category archive page runs over category.php template.

Also is there a way to know if loaded page is post formats archive page?

Yes there is. You can use is_archive(); Conditional Tag.

UPDATE

is there a way to show all posts from one post format? For example using archive.php template show all posts with 'image' or 'quote' post type?

Yes there is. You can display specific format posts in your archive.php with pre_get_posts action hook. If you take a look at WP_Query arguments you will find tax_query. It is an array of taxonomy parameters.

Example usage:

//in functions.php
add_action( 'pre_get_posts', 'wpse_show_posts_by_format' );
function wpse_show_posts_by_format($query){
  //We are not in admin panel and this is the main query
  if( !$query->is_admin && $query->is_main_query() ){
    //We are in an archive page
    if( $query->is_archive() ){
      $taxquery = array(
        array(
          'taxonomy' => 'post_format',
          'field'    => 'slug',
          'terms'    => array( 'post-format-quote', 'post-format-image' )
        )
      );
    //Now adding | updating only to main query 'tax_query' var
    $query->set( 'tax_query', $taxquery );
    }
  }
}

Hope it helps!

share|improve this answer
    
Thanks, but is there a way to show all posts from one post format? For example using archive.php template show all posts with 'image' or 'quote' post type? –  vlad Sep 2 '13 at 7:51
    
@vlad, Yes there is. I will update the answer as reference : ) –  iEmanuele Sep 2 '13 at 7:55
    
@vlad, please see the answer : ) –  iEmanuele Sep 2 '13 at 8:21
1  
Post format are taxonomy terms. And they should be / can be treated as taxonomy terms. –  G. M. Sep 3 '13 at 2:06

Post format is a taxonomy.

Not post type, nor meta.

The difference from categories, tags, custom taxonomies and post format is that the post format terms can be (at this time) a set of 9 terms.

Note that the post format 'Standard' does not exist, setting a post to standard post format means set no post format.

So arbitrary post format cannot exist, but the ones that exist are taxonomy terms.

Note also that the slug of this taxonomy is something like post-format-{$format}, e.g. post-format-quote.

What is parent template file that is used when there is no specified template file and what is specified template file that covers all post formats templates?

Once they are taxonomy terms, you have to see Template Hierarchy regarding taxonomy:

So taxonomy-post_format-{$slug}.php (e.g. taxonomy-post_format-post-format-quote.php) is the first template thet wp look for.

After that taxonomy-post_format.php (this is included in twentythirteen theme), than taxonomy.php, archive.php and index.php.

Also is there a way to know if loaded page is post formats archive page?

Again it is a taxonomy. So is_tax() or is_tax('post_format') and is_tax('post_format', 'post-format-quote') will all work.

I bet that now you are asking what is the url that request post format archives?

I've to say that when no pretty permalinks are activated the link is something like http://example.com/?post_format=quote (http://example.com/?post_format=post-format-quote will also work).

With pretty permalinks activated, by default, it is something like: http://example.com/type/quote. (http://example.com/type/post-format-quote/ will also work)

Note that the url http://example.com/type/ (with no given type) will result in a 404 error.

I've said 'by default' because the rewrite base 'type' for post format can be changed via the post_format_rewrite_base filter.

However, to get the correct link to the post format archive is possible to use the get_post_format_link function.

share|improve this answer

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.