Adding content above Layout - Content Left, Sidebar Right

@Rad @paul.r

The last question I have is if I want to add the same global block on top of a specific category/archive page, what is the code I have to add in the functions.php?

Hi Andy,

It’s going to be similar, example, let’s take this part

  if( is_home() ) {

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

You can enhance it to something like this,

  if( is_home() ) {

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

  if( is_category( 3232 ) || is_category( 'news' ) ) {

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

  if( is_archive() || is_tag() ) {

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

  if( is_tax('product_cat', 'music') || is_tax('product_cat', 'audio') ) {

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

There is no limitation, as long as you use the conditions provided by Wordpress.

Thanks!

Hi!

Thanks for the response. So here is what I did:

https://puu.sh/CTf5P/4c3f9dc617.png

I can confirm that the category ID is 2131 for College Guides, but it doesn’t seem to work.

After the is_category, I’ve tried:

College Guides
college guides
College-Guides
college-guides

I also tried adding add_action(‘x_after_view_ethos__landmark-header’, ‘add_custom_content’); after the last }

Tried to copy the same code as the homepage and replaced the is_home part:

https://puu.sh/CTfhT/554b24fb09.png

Hi Andy,

You don’t need to re-add the same code, you have to just edit the existing one. And this sample is_category( 3232 ) || is_category( 'news' ) are different categories, I only use it as the demonstration that you could use both category ID and category slug.

If this is your existing code

// 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');

You have to modify it and will look as this

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

  if( is_home() ) {

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

  if ( is_category( 2131) ) {

      echo do_shortcode('[cs_gb id=2044]');

  }

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

Thanks!

Awesome, worked great.

Sorry, I’m terrible with these things. :sweat_smile:

No worries. Have a great day! :slight_smile:

You as well!

No problem.
If you need anything else we can help you with, don’t hesitate to open another thread.

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