I have a post part that is called into my single.php and looks like this:

<div class="main-content col-md-8" role="main">
    <?php while (have_posts()) : the_post(); ?>
        <?php get_template_part( 'content', get_post_format() ); ?>
        <?php comments_template(); ?>
    <?php endwhile; ?>
</div> <!-- end .main-content -->
<?php get_sidebar(); ?> // col-md-4

Then my content.php looks like this:

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php if ( is_single() ) : ?>
            <h1><?php the_title(); ?></h1>
        <?php else: ?>
             <h1><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
        <?php endif; ?>

        <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
            <figure class="entry-thumbnail">
                <?php the_post_thumbnail( 'post-large' ); ?>
        <?php endif; ?>

        <div class="entry-meta">
                // Display the meta information
    </header> <!-- end entry-header -->

    <div class="entry-content">
            if ( is_search() ) {
            } else {
                the_content( __( 'Continue reading &rarr;', 'my_theme' ) );
    </div> <!-- end entry-content -->

Now, I want to create another part just like the first block of code(col-md-8 and sidebar col-md-4) where I would have my post content and sidebar but I want to have my post thumbnail and post meta full width(col-md-12) above that block.

In that case I am wondering how to tweak my code on content.php where the post thumbnail and post meta are called in order to have them displaying above my col-md-8 and sidebar(col-md-4) only for this specific situation.

A solution would be to have a col-md-12 div above my col-md-8 div and sidebar and add my post thumbnail and post meta code there but then these would be outside the loop and I wouldn't be able to use content.php for this situation and I would like to use content.php for all my post layout variations for easier maintenance. And having the post thumbnail and post meta code on their own on a div col-md-12 outside the loop would not be ideal as I need to access the post meta for each specific post.. So, just wondering what would be the ideal solution to achieve this.

  • What "specific situation"? You haven't identified any programmable logic. When... under what circumstances... is this switch supposed to occur? All you've really said is "sometimes".
    – s_ha_dum
    Commented Nov 28, 2015 at 15:09
  • Basically I am looking into implementing the same set-up as in the code above but I wish to have the thumbnail above the col-md-8 and sidebar in a col-md-12. I am just wondering what's the "cleaner" way to achieve this.
    – Madeirense
    Commented Nov 28, 2015 at 16:20
  • You say "only for this specific situation". What one specific circumstance?!?!?! As for "cleaner" I don't know what way you are trying now. Your question, while long, is missing the important details and I don't feel like guessing.
    – s_ha_dum
    Commented Nov 28, 2015 at 16:24
  • I am not sure what else I need to provide. I have the code above for a layout with my main content on a col-md-8 and sidebar on a col-md-4. What I am trying to do now is have a variation of this layout but with the post thumbnail above the col-md-8 and col-md-4 sidebar. So it would occupy the width of the col-md-8 and sidebar col-md-4 on a col-md-12. What I am wondering is what is the best way to achieve this. Hope I am being clear.
    – Madeirense
    Commented Nov 29, 2015 at 17:20

1 Answer 1


What about calling another content part above the sidebar and the post content block with a col-md-12 class. Call the Loop inside there with only the thumbnail and meta / any information you want there.

Then you call the rest of the post in the other content part which has a col-md-8 class and is positioned next to the sidebar.

  • Yes, that would work, but I would then have a loop for that bit and another loop inside the col-md-8. Just wondering if that's fine or if its a bit messy having two loops.
    – Madeirense
    Commented Nov 28, 2015 at 16:14

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.