ACF Options fields in Wordpress theme header.php

/ Published in: PHP
Save to your folder(s)

Simple sample of my header.php trying to grab the 'address' field from the Options page, but no luck. Same with my footer.php. BTW it works fine in my other template files (page.php etc)

Copy this code and paste it in your HTML
  1. <!DOCTYPE html>
  2. <html <?php language_attributes(); ?>>
  3. <head>
  4. ...css, javascript etc
  5. </head>
  6. <body>
  7. <div id="header_bg">
  8. <div id="header">
  9. <div id="address"><?php if (get_field('address', 'options')) { the_field('address', 'options') } ?></div>
  10. </div>
  11. </div>
  12. ...nav etc

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.