Site logo

[Support request] Element in multiple hooks

Home Forums Support [Support request] Element in multiple hooks

Home Forums Support Element in multiple hooks

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1758329
    David

    Hello,

    Is there a way to put an element in more than one hook location using GP premium

    #1758402
    Leo
    Staff
    Customer Support

    Hi there,

    Unfortunately not. You would need to create multiple elements.

    #1758496
    David

    No problems, that is a shame though.

    #1758851
    David
    Staff
    Customer Support

    Hi there,

    out of interest – what would be the use case ? Be good to know how you’re intending to use them.

    #1758857
    David

    It was just for example placing a button after the primary nav on desktop and in mobile below the nav

    #1758901
    David
    Staff
    Customer Support

    Aah ok … depending on the layout you could probably use some CSS with the right hook to position. But it sounds like it would be simpler to use 2 x elements.

    Interesting though – we’ll have a chat internally to see if that could be something for the future.

    #1758923
    David

    Thank you for the consideration, is there much of a resources overhead for for having multiple elements. I’m just trying to get my head around the new template system to see if I can us into style an events manager plugin layout, only problem is how I find out the custom field names used.

    #1760045
    David
    Staff
    Customer Support

    is there much of a resources overhead for for having multiple elements.

    No not really. Theres hardly any difference between them and you adding the content directly to the post editor.
    There is the Display Rules which is setting an IF condition for the hooks content to be displayed, but this is super efficient.

    The plugin developer should be able to provide you with a list of the their post meta ( custom fields ).

    Or if you want to get your hands dirty – this article provides a function that will display all the meta fields being used on the post your viewing:

    https://wpbeaches.com/show-all-post-meta-keys-and-values-for-a-post-in-wordpress/

    #2003378
    Jon

    I have the same request. Use case is this:
    I have created a block element CTA (promoting an eBook for example) and I would like to show it in two hook locations. Once after the featured image, and again at the end of the content. This seems like it should be possible. I don’t like the idea of creating multiple copies of the same element.

    #2004023
    David
    Staff
    Customer Support

    Hi there,

    there is no functionality in GP Elements that would allow that.

    The only work around it is to create your own custom hook inside the two theme hooks, and then hook your block element inside that. Heres an example function:

    add_action('generate_before_header', 'db_custom_hook');
    add_action('generate_before_footer', 'db_custom_hook');
    
    function db_custom_hook(){
    	do_action('custom_hook');
    }

    Then in the Block element you can select Hook > Custom Hook –> named: custom_hook to add a block element to two places.
    You just need to update the hook names in the add_action functions to suit your needs.

    #2135875
    Andrew

    This feature would be great. I currently have an element I need to display in 2 different areas – and also use as a content template on a CPT archive page.

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Element in multiple hooks’ is closed to new replies.