I want to display the header menu based on the certain pages. So I created a true/false ACF for every page as a toggle.
I have found the solutions for getting the acf fields from another post using get_field('field_name'), $post->ID). However, I don’t want to get the field from only one particular page.
I have tried using get_header('', array('menu_display', get_field('field_name') )) in a template and then use the args in the header.php like this <?php if ($args['menu_display']) ?>. It always appears to be false for some reason.
Turns out I only needed to call get_field() in the header.php. That didn’t work for me at first I’m not sure why but toggling on/off the true/false ACF and updating the page fixed it. Quite tedious cuz I had to go through every page to do that.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users