How to add Global Block as a footer to a specific page

Hi, I’ve used code previously given by yourselves to add a global block as a footer to every page which is great, but I’m now needing to add a global block as a footer to one specific page and not any others. I’ve already tried to search the forum for a solution but can’t find anything.

Here’s the code I’ve already got to put a global block on every page:

add_action( 'x_before_view_footer_base', 'x_print_footer_global_block' );
function x_print_footer_global_block(){
	echo do_shortcode( '[cs_gb id=1573]' );
}

I hope you can help!

Thanks!

Hi @core365,

Thanks for reaching out.
If you are using the Pro then you can add the Global Block to a specific footer and assign it to the specific page. But if you are using the X, you need to add the following code to check the specific page with your existing code.

global $post;
$post_id=$post->ID;
if($post_id==1234)
{
    //your code here.
}

The complete code will look like the following, please replace the post_id value with your specific page id. Please find the article to find the post id: https://theme.co/docs/how-to-locate-post-ids

add_action( 'x_before_view_footer_base', 'x_print_footer_global_block' );
function x_print_footer_global_block()
{
    global $post;
    $post_id=$post->ID;
    if($post_id==1234)
    {
        echo do_shortcode( '[cs_gb id=1573]' );

    }
}

Please remember that the above code will work if copied as it is and doesn’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 really do not provide support for custom codes which means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

Hi @tristup,

Spot on! That worked out perfectly, thank you!

Thanks for your time and help.

Hi @core365,

We’re glad that my colleague was able to help you with your issue! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

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