Home › Forums › Add-ons › Options Page › Header and Footer Scripts in Options › Reply To: Header and Footer Scripts in Options
Yes. You can create an options page for content to be added to the entire site. Set the formatting on the textarea field to no formatting and then in the header of footer include the content from the field.
<?php the_field('my_code_field', 'options'); ?>
</head>
For individual pages/posts you’d do the same thing but, but you need to tell acf the right post ID
<?php
$queried_object = get_queried_object();
if ($queried_object->ID) {
the_field('my_code_field', $queried_object->ID);
}
?>
</head>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.