I am creating a video-archive page for all the posts_format with video.

Currently, I have:

<?php $format = has_post_format('video', $post_id); ?>      

<?php

if($layout != "fullwidth") {
    echo '<div class="page_inner">';
}

if (have_posts()) : while (have_posts()) : the_post();

    vntd_blog_post_content();

endwhile;

This is not working, but I do not think I'm far off.

What am I doing wrong?

  • Then how would I display this archive page for only and all video post formats? – Travis Patron Mar 20 '15 at 20:30
  • http://example.com/type/video/ – Milo Mar 20 '15 at 20:34
  • I'm trying to add a archive-video.php file and also a single-video.php file to fill that URL. I've also tried taxonomy-video.php. No luck so far. – Travis Patron Mar 21 '15 at 23:39
  • Perhaps I need first to register 'video' as a post type? Yet it appears in my post editing sidebar ... – Travis Patron Mar 22 '15 at 0:24
up vote 1 down vote accepted

I'm not quite sure if you need a dedicated page or a true archive page for this, but here is the two options

If you need a dedicated page to display video post formats, you can make use of a custom query with a tax_query as post_format is just another build in taxonomy with post-format-video being a term to the post_format taxonomy. Your query on your page template should look something like this

$args = array(
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            'terms' => 'post-format-video'
        )
    )
);
$q = new WP_Query( $args );

if ( $q->have_posts() ) {
    while ( $q->have_posts() ) {
        $q->the_post() );

        // Your loop

    }
    wp_reset_postdata();
}

If you need to create a specific archive page for video post format only, you can create a special taxonomy template for this by simply copying your index.php template and renaming it to taxonomy-post_format-post-format-video.php. Everytime you visit this taxonomy page at example.com/type/video or you click on a post-format-video link, this template will be exclusively used to display video post format posts.

Reference: Template Hierarchy

EDIT

Your comment

news.diginomics.com/type/video What do I name my php file to take advantage of this URL hierarchy?

As I stated, you need a taxonomy template as post_format is one of the 4 build in taxonomies. For a video post format specific template, copy your index.php and rename it

taxonomy-post_format-post-format-video.php

This template will be used everytime you visit news.diginomics.com/type/video

For interest sake, please see this answer I have done about taxonomies

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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