[Resolved] GB local template as custom field or shortcode

Home Forums Support [Resolved] GB local template as custom field or shortcode

Home Forums Support GB local template as custom field or shortcode

  • This topic has 7 replies, 2 voices, and was last updated 4 months ago by David.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #2176271

    I am creating a header for each post category. Each header will have the category title, a subheading (different than the taxonomy description), and a GB grid different for each category. Right now, I am using a block element using the hero hook for each category which I think is a bit of an overkill. I considered this approach because of the fact that the grid is different for each category. I can have the title as a dynamic element and the subheading as a custom field but I would like to be able to only have one hero element that displays each grid dynamically depending on the category. If I was to create local templates that house each GB grid, would there be a way to display each local template grid conditionally and in a certain position inside the hero element?

    Customer Support

    Hi George,

    i am not sure its possible – any chance we can see the current category pages ? May give us some ideas for options.


    Attached is the site URL. Each category has a set of infoboxes at the top. It’s those infoboxes that I want to be dynamic.

    Customer Support

    First off – apologies for the late reply, this slipped through our system.
    If I understand correctly you will need:

    a) 1 x global dynamic hero
    b) a big bunch of templates for each of the grids.

    One thing that comes to mind would be:

    1. Create a Hook inside a Shortcode by adding this PHP Snippet:

    function db_hook_inside_shortcode($atts, $content = null) {
          return ob_get_clean();
    add_shortcode('hooky_shortcode', 'db_hook_inside_shortcode');

    You can then add the ‘[hooky_shortcode]’ shortcode inside your current hero where the grids are to be displayed.
    This will provide you a hook named: inside_hero_hook.

    2. You can now create other Block Elements for your Grids and Hook them into inside_hero_hook


    Ah, yeah, that snippet! Unfortunately, that defeats the purpose of what I am trying to avoid. I already have separate category header elements that contain the separate icon boxes so the solution would not be an improvement. Was hoping I could hook reusable blocks or GB local template blocks instead to keep things organized. I am happy to leave as is if it’s complicated.

    Customer Support

    My view was, you would either have:

    a. A Global Block Element + x Number of Local Templates – lets say 10 for arguments sake. So in total we have 1 + 10 ‘templates’

    b. A Global Block Element + 10 specific Elements – so thats still a total of 11 ‘templates’

    Which in comparision would be 1 more then you have today.
    So what am i missing – why would option a) be an improvement ?

    The Only other alternative i can think of is to use the Remove container condition on the container blocks and use the Post Meta option. You can then use a Custom Field to determine wether that container is displayed or not. But that will only work on Posts and Pages.


    Yeah, I get you. It’s just that option a. would have the blocks separated in their own custom post types instead and not mixed with the elements. Anyway, I think I am going to leave it like that. The better option would be to have ACF repeaters for each archive that would dynamically display the icon boxes. I dream that GB with the upcoming query loop would be able to achieve that in the future!

    Customer Support

    Yeah the ACF repeater method sounds like the better way to go and, not on initial release, but looping through meta is something we have planned for GB 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.