Add global block to post page

Hello, I would like to add a global block in all the post page. Is it possible?

Hi,

Yes, that’s possible.

Where would you like to add it?

You can try adding the code below in your child theme’s functions.php file.

function add_global_post() {   
    if(is_singular('post')){
  echo do_shortcode('[yourshortcode]');
}}
add_action( 'x_before_the_content_begin', 'add_global_post', 10 );

Change this [yourshortcode] with your global block shortcode

For more information


Hope that helps.

Thank you, I would like to add it as a footer…

Hello @dcheese,

Thanks for updating the thread. :slight_smile:

In that case you just need to replace the code with following:

function add_global_post() {   
    if(is_singular('post')){
  echo do_shortcode('[yourshortcode]');
}}
add_action( 'x_before_site_end', 'add_global_post', 10 );

Thanks.

1 Like

That’s great! Thank you!

You are most welcome. :slight_smile:

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