Adding content above Layout - Content Left, Sidebar Right

Hello.

If you take a look at the screenshot

https://puu.sh/CSJ3f/6dc58c81ec.png

I’m trying to add the slider and 4 images you see on the left on top of the page in the center. Basically like this:

https://puu.sh/CSJ6M/22ac2a865e.png

So then once you scroll down, you’ll see the regular Content left, sidebar right content.

How can I do this with the Layout - Content Left, Sidebar Right page layout in Cornerstone? If this is do-able without Cornerstone, even better. I can’t use the Blank - No Container, Header, Footer layout because there are SO many responsiveness and other issues.

Thanks!

Hi Andy,

Thanks for reaching out.

This seems related to your other thread, may I know which page is this? I checked the sites from your account and the home page is different than your screenshot. But, that would require template customization. Before we continue, please check these first

https://theme.co/apex/forum/t/customizations-best-practices/205,
https://theme.co/apex/forum/t/how-to-upload-xtheme-to-child-theme/43246/2,

It’s for familiarization of how template customization should be done.

Let’s get started :slight_smile:

  1. Please copy the file /x/framework/legacy/cranium/headers/views/ethos/template-layout-content-sidebar.php to your child theme (eg. /x-child/framework/legacy/cranium/headers/views/ethos/template-layout-content-sidebar.php ).

  2. Add this content to your child theme’s template-layout-content-sidebar.php

<?php if ( is_page( 2323 ) ) do_shortcode('[cs_gb id=381]'); ?>

The 2323 is the page ID where you wish to display it, please check this on how to get it https://theme.co/apex/forum/t/setup-how-to-locate-post-ids/59.

Then [cs_gb id=381] is a global block shortcode where you should create the slider and those 4 images. Please check this https://theme.co/apex/forum/t/global-blocks/24723

The resulting content of /x-child/framework/legacy/cranium/headers/views/ethos/template-layout-content-sidebar.php should be similar to this

<?php

// =============================================================================
// VIEWS/ETHOS/TEMPLATE-LAYOUT-CONTENT-SIDEBAR.PHP
// -----------------------------------------------------------------------------
// Content left, sidebar right page output for Ethos.
// =============================================================================

get_header();

?>

  <div class="x-container max width main">

<?php if ( is_page( 2323 ) ) do_shortcode('[cs_gb id=381]'); ?>

    <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', 'page' ); ?>
          <?php x_get_view( 'global', '_comments-template' ); ?>
        <?php endwhile; ?>

      </div>

      <?php get_sidebar(); ?>

    </div>
  </div>

<?php get_footer(); ?>

Thanks!

Hey!

Thanks for the solution, can you clarify what I do with the 2323 page ID?

Hi Andy,

The 2323 number is an example of page ID. You should replace it with your page ID:

If you would like to print the global block shortcode in multiple pages, please the code to this:

<?php if ( is_page( array(1234, 5678, 9870) ) ) do_shortcode('[cs_gb id=381]'); ?>

Hope it helps :slight_smile:

@Rad

So when I change my “Your Homepage Displays” to a static page, it no longer shows my latest posts. How do I find the page ID of my homepage that isn’t a page I actually created?

Hey Andy,

When the page is used as your blog index, is_page() will no longer work. You will used other conditional tag instead like is_home() for the blog index, is_archive() for archive pages. You can check out the codex here for the rest of the available conditions that you can use:

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

@Rad @thai

Hi.

There are only 4 php files in my /x/framework/legacy/cranium/headers/views/ethos/ folder. I can’t find the template.

https://puu.sh/CSZiD/03056f4f2a.gif

On top of that, there’s like no folders in my x-child folder.

https://puu.sh/CSZoS/dd3ba5bb6c.gif

Hi Andy,

  1. Do you mean the page templates?

It’s located in wp-content/themes/x/framework/views/ethos

  1. Yes, the child theme by default don’t have those folders. You will need to create the folders and copy over the files that you want to override. Kindly review the link below.

Thanks

@Rad @RueNel

Hi.

Okay here’s what I did:

  1. Found the template-layout-content-sidebar.php in wp-content/themes/x/framework/views/ethos
  2. Copied the file into my wp-content/themes/x-child/framework/views/ethos
  3. Went into my WordPress Theme editor of my child theme and went to the template php file
  4. Added the <?php if ( is_home() ) do_shortcode(’[cs_gb id=2040]’); so it’s like:

https://puu.sh/CSZQ9/b8d36f4628.png

I know you see ( is_home() && is_front_page() )

But I’ve already tried:

  1. ( is_home() )
  2. ( is_home() & is_front_page() )
  3. ( is_home() && is_front_page() )
  4. ( is_front_page() )
  5. ( is_front_page() && is_home() ) {
    // Default homepage
    } elseif ( is_front_page() ) {
    // static homepage
    } elseif ( is_home() ) {
    // blog page
    } else {
    //everything else
    }

I’ve cleared my cache every time, my homepage never updated with my global block.

https://puu.sh/CSZNm/642ef01a4f.gif

Hello Andy,

You need this line:

<?php if ( is_home() )  : ?>
  <?php echo do_shortcode('[cs_gb id=2040]'); ?>
<?php endif; ?>

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

@Rad @RueNel

It didn’t change anything either.

https://puu.sh/CT00y/1a89769d35.png

Cleared the cache as well.

Hi,

In that case, would you mind providing us with login credentials so we can take a closer look? Please provide following information:

Set it as Secure Note

  • Link to your site
  • WordPress Admin username / password

All the best!

Of course, here it is:

Hey Andy,

The template you have modified is for pages only. You will need to assign this to your blog index page or any page that uses the Layout - Content Left, Sidebar Right page template.

To resolve your issue, you can simply add this PHP code block in your child theme’s functions.php file instead. No template modifications needed.

// Displaying custom Content on Blog Page
// =============================================================================
function add_custom_content () {

  if( is_home() ) {

    echo do_shortcode('[cs_gb id=2040]');
  
  <?php }

}
add_action('x_after_view_ethos_post-slider', 'add_custom_content');
// =============================================================================

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

Hi!

Thanks for the information. I’m only looking to place this global block on my blog homepage anyways.

I’m getting this error when placing that code in my functions.php

Your PHP code changes were rolled back due to an error on line 90 of file wp-content/themes/x-child/functions.php. Please fix and try saving again.

syntax error, unexpected ‘<’

Line 90 is the <?php }

Hello Andy,

There was a typographic error in the code in my reply. Have it updated into this one:

// Displaying custom Content on Blog Page
// =============================================================================
function add_custom_content () {

  if( is_home() ) {

    echo do_shortcode('[cs_gb id=2040]');
  
  }

}
add_action('x_after_view_ethos_post-slider', 'add_custom_content');
// =============================================================================

Please let us know if this works out for you.

Hi.

It still didn’t do anything.

https://puu.sh/CT2tF/6522da154d.png

Hello Andy,

I went ahead and edited your functions.php file.
I used this code instead:

// Displaying custom Content on Blog Page
// =============================================================================
function add_custom_content () {

  if( is_home() ) {

    echo do_shortcode('[cs_gb id=2040]');
  
  }

}
add_action('x_after_view_ethos__landmark-header', 'add_custom_content');

The section were place outside the container just right below the navbar.

Please check it now.

Omg!

It works!

It’s absolutely beautiful :slight_smile:

Thank you all for your help. This was such a struggle for me haha!

You’re most welcome!
We’re glad we were able to help you out.