Global Block auto insertion

So this post is epicly cool and solved the problem. https://theme.co/apex/forum/t/add-global-block-to-post-page/32156

But Iā€™m wondering if you could help me figure out how to make it change based on a category and/or tag? I move from live to library for events and Iā€™d like the global block to change too. I have one for Events Live and another for Recorded Library. Thanks in advance.

Hello Eric,

Thanks for asking. :slight_smile:

For that you will have to use a bit of more conditional tags and custom development which falls outside the scope of support we can offer. That being said you can take a look at following articles to lean more about conditional tags.

https://codex.wordpress.org/Conditional_Tags
https://codex.wordpress.org/Conditional_Tags#A_Category_Page

Thanks.

I have over 100 licenses. Do you think maybe you can help me out please?

Hello @ericgreenspan,

Thanks for updating in! With one license or several others, we will always try our best in anyway we can. @Darshana has given you a good reference on how you can pull off what you want to do. With the code from the thread and the conditionals tags from the link, you can have something like this:

function add_global_post() {   
  
  // single post
  if( is_singular('post') ){
    echo do_shortcode('[yourshortcode]');
  }

  // category page
  if( is_category('category_name') ){
    echo do_shortcode('[yourshortcode]');
  }

  // tag page
  if( is_tag('tag_name') ){
    echo do_shortcode('[yourshortcode]');
  }

  // display a shortcode when in a particular term ()
  if( has_term('term_name') ){
    echo do_shortcode('[yourshortcode]');
  }

}
add_action( 'x_before_the_content_begin', 'add_global_post', 10 );

This code should be able to serve as a example for you to start with your customizations. Feel free to change the values and the shortcode in the code above.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Thank you for your understanding.

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