Site logo

Archived topic

call different Header & Hook Element based on ACF field

3 replies · Started by jasond on July 3, 2020

Viewing posts 1–4 of 4

I want to build two different post layouts so I just set up a True/False Custom Field (ACF field) for Posts, is there any way to load different Header/Hook Elements based on this field?

Many thanks

Hi there,

you can use the generate_header_element_display and generate_hook_element_display filters:

https://docs.generatepress.com/article/generate_header_element_display/

https://docs.generatepress.com/article/generate_hook_element_display/

Then you just need to create a condition based on that field to show or hide the relevant one.

My personal approach is to register a Custom Taxonomy which can be used within the Elements display rules. Idea in more detail here:

https://generatepress.com/forums/topic/disabling-element-using-page-editor-metabox/#post-980207

Dear David

Many thanks for your ideal solution. It works great for me!

Glad to hear that.

This archived topic is closed to new replies.