I'v tried really a lot of solutions, and the one that works, it works half a way.

Inside single.php I'v added

<?php while ( have_posts() ) : the_post(); ?>

<?php if( has_post_format('video')) {

get_template_part( 'template-parts/content', 'video'); } ?> 

Then i created content-video.php. Now the thing is it appears as it should but since it's called inside single.php for some reason the function doesnt stop, like, if it has format video show the post trough content-video.php only, if the post it's not video post format run a normal post (single.php).

A reason why i want to do this, is that i want to style differently video post formats. So what do I currently have? I have the one i want (video post format) but below it's again the whole single.php stuff. So again the post, the image, the title, the sidebar.

I guess i only need to stop the loop in single if it has post format video, but cant figure/see a way.

My single.php it's here http://pastebin.com/XwqiZrEd

So what I'm missing, because in 4am i am missing something for sure :D ?

1 Answer 1


What about add else { after get_template_part( 'template-parts/content', 'video'); }?

EDIT (1) :

* The template for displaying single posts.
* @package SN
get_header(); ?>
<?php while ( have_posts() ) : the_post(); ?>
    <?php if( has_post_format('video')) {
   get_template_part( 'template-parts/content', 'video'); }else{ ?>        
<div id="content-wrapper">
    <div id="primary" class="content-area">
            <main id="main" class="site-main" role="main">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
    <div class="entry-content">
            <?php the_content(); ?>
            <?php if( 'scoreboard' == get_post_type() ) {  ?>
  <?php } else { ?>
    wp_link_pages( array(
        'before' => '<div class="page-links">' . __( 'Pages:', 'sport-news' ),
        'after'  => '</div>',
                     ) );?>
       </div><!-- .entry-content -->
       <?php } 
     <footer class="entry-footer">
    <?php sport_news_entry_footer(); ?>
    </footer><!-- .entry-footer -->

  • Hey Kika, well that's the first thing i have tried, but getting an error. I understand that i need to add else and close it, but cant find a right way, where/how to add it inside single. That's what you get when you work so late. So inside else i would have to add basically a whole single.php?
    – Max
    Aug 29, 2015 at 2:01
  • I edited my post with full your code after editing. Aug 29, 2015 at 2:14
  • 1
    Thanks so much. I was doing that, but i guess on the wrong way. This was the issue, at the bottom <?php } }?> and i was trying to add it twice. Thanks so much, kind regards.
    – Max
    Aug 29, 2015 at 2:20
  • Could i bother you for one more thing. Already tried to move the closing part everywhere but currently it shows sidebar from single.php and i dont want sidebar there. Where to add it so the sidebar doesnt get called inside video format - post. There is an endwhile and if add it below it, an error, if i add it above, still sidebar gets called. Any idea? Sorry for bothering you, i just recently started to learn php :D
    – Max
    Aug 29, 2015 at 2:29
  • 1
    Yea i moved <?php endwhile; after get_sidebar. You r awesome! Have a nice day! Thanks
    – Max
    Aug 29, 2015 at 2:44

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.