- This topic has 10 replies, 5 voices, and was last updated 4 years, 1 month ago by
Andrew.
-
AuthorPosts
-
April 30, 2021 at 2:22 pm #1758329
David
Hello,
Is there a way to put an element in more than one hook location using GP premium
April 30, 2021 at 4:54 pm #1758402Leo
StaffCustomer SupportHi there,
Unfortunately not. You would need to create multiple elements.
April 30, 2021 at 9:08 pm #1758496David
No problems, that is a shame though.
May 1, 2021 at 5:23 am #1758851David
StaffCustomer SupportHi there,
out of interest – what would be the use case ? Be good to know how you’re intending to use them.
May 1, 2021 at 5:30 am #1758857David
It was just for example placing a button after the primary nav on desktop and in mobile below the nav
May 1, 2021 at 6:09 am #1758901David
StaffCustomer SupportAah 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.
May 1, 2021 at 6:29 am #1758923David
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.
May 2, 2021 at 2:44 am #1760045David
StaffCustomer Supportis 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/
November 13, 2021 at 6:31 pm #2003378Jon
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.November 14, 2021 at 8:11 am #2004023David
StaffCustomer SupportHi 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_hookto add a block element to two places.
You just need to update the hook names in the add_action functions to suit your needs.February 27, 2022 at 4:15 pm #2135875Andrew
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.
-
AuthorPosts
- The topic ‘Element in multiple hooks’ is closed to new replies.