Global block / shortcode on blog page

Hey guys.

I would like to add a Global Block / Shortcode to my blog page.
For my web shop I have used this code in functions.php:

 function shop_header() {
if ( is_product_category() || is_product() ) : ?>
		<div class="x-header-shop">
		    <?php echo do_shortcode('[cs_gb id=1182]'); ?>
		</div>
	<?php endif; 
}
add_action('x_before_view_global__slider-below','shop_header', 30);

How do I edit the blog page? I have Integrity stack with Masonry posts in there, but I would like it to display my global block, which would be additional information before blog posts.

Would you kindly point me to what is the hook/file I have to edit?
Best Regards to great support Team!

Hi David,

Thanks for reaching out.
You need to use the proper conditional tag to print the Global Blocks into the Blog page. Please find the below code which helps you to inject the code into the Blog page only.

function blog_page_global_block() 
{
    if(is_home())
    {
    ?>
        <div class="x-header-shop">
            <?php echo do_shortcode('[cs_gb id=1182]'); ?>
        </div>
    <?php 
    }
}
add_action('x_before_view_global__slider-below','blog_page_global_block', 30);

Remember that the above code will work if copied as it is and don’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started custom coding on your own if there’s no option offered in our theme or the products we bundle.
We do not provide support for custom codes that means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

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