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.
Thank you in advance!
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.