Blog posts with right sidebar and full-width header

Until now I have succeeded in having the blog posts in a layout with main content n the left and sidebar on the right.

The design I need to follow describes that there also should be a section ABOVE these two sections, which will be full-width and would contain the post’s feature image along with the excerpt.

I know some things about templates and customizing, but I need some directions on which file(s) should I copy and edit on my child’s theme structure in order to get this result. I’m using ethos stack with pro theme.

Hello There,

Thanks for posting in! To get you started with your modifications, you will need to copy the wp-content/themes/x/framework/views/ethos/wp-single.php file and place it in wp-content/themes/x-child/framework/views/ethos/wp-single.php. You will be adding the fullwidth section on top, right before the container div.

<?php

// =============================================================================
// VIEWS/ETHOS/WP-SINGLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Ethos.
// =============================================================================

$fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );

get_header();

?>

  <div class="x-container custom-content">
    <div class="x-column x-1-1">
      <p class="mal">Add your fullwidth contents here</p>
    </div>
  </div>

  <div class="x-container max width main">
    <div class="offset cf">
      <div class="<?php x_main_content_class(); ?>" role="main">

        <?php while ( have_posts() ) : the_post(); ?>
          <?php x_get_view( 'ethos', 'content', get_post_format() ); ?>
          <?php x_get_view( 'global', '_comments-template' ); ?>
        <?php endwhile; ?>

      </div>

      <?php if ( $fullwidth != 'on' ) : ?>
        <?php get_sidebar(); ?>
      <?php endif; ?>

    </div>
  </div>

<?php get_footer(); ?>

Hope this helps. We would loved to know if this has work for you. Thank you.

Hi!

Thank for your response.
Actually, this was also my original thought, but it doesn’t work!

The thing is, that in the custom-content block you cannot access current post’s data (featured image and excerpt).
It’s outside of the Loop!
And I can’t move the while (have_posts()) on top of course.

Any other thoughts?

After some more research I used another loop for the custom-content and the function rewind_posts() like that :

`

<?php if(in_category(417)): // Is it a Blog Article ?> <?php while ( have_posts() ) : the_post(); ?>
<?php the_post_thumbnail('diane-featured'); ?>
<?php the_excerpt(); ?>
<?php endwhile; ?> <?php rewind_posts(); ?> <?php endif; ?>`

Hi,

Glad to know you were able to figure it out.

Have a nice day! :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.