Want to make header and footer CMS driven sothat Editors can modify its content from wordpress admin section
-
06-03-2021 - |
Question
First time I am working on WordPress CMS but have fair experience in other CMS products such as Umbraco, Tridion , sitecore etc.
I am using ACF (advance custom field) to create the content forms in CMS but I have a requirement to make the content of header and footer section also CMS driven.
For example I have website logo, site banner in the header and few images in the footer sections.I want to provide privilege to our Editors to modify these images (logo, banner and footer images) from CMS interface similar to other content managed via forms created with the help of custom fields of ACF plugin.
I am just thinking to create two pages ( header & footer ) but it looks that with this approach I will not be able to get the header.php
and footer.php
as the page template. Also it does not seem a good approach to me.
Can somebody suggest me the best approach to achieve this?
Solution
You can create pages header
and footer
.
In your header.php
and footer.php
, you just need to call the fields using the ID of the page you created. Check the documentation
If you need to make that editing, available in the fron-end, you can use acf_form
. Check the documentation
OTHER TIPS
You can add an "options" page to the WP admin with this snippet, add it to your functions file.
// acf options page
if( function_exists('acf_add_options_page') ) {
$option_page = acf_add_options_page(array(
'menu_title' => 'Theme Options',
));
}
Then create your custom fields in ACF and add them to Theme Options. Call the fields in your header.php and footer.php with this code (change "logo" to your field name)
<?php the_field('logo', 'option'); ?>
These can then be updated in the Options page.