wordpressadvanced-custom-fields

How to add a custom field to my page header


Is there a way to add a custom field to change the image displayed in my web site's header? I want the same imageto be displayed in every page, so I dont know how to make a general custom field instead of a field specific for each page.

<?php
  $img = the_field('background_url'); 
?>

Solution

  • Add Options page for ACF with the help of below code:

    if( function_exists('acf_add_options_page') ) {
        acf_add_options_page();
    }
    

    and then assign options to acf field. now you can access this common field with <?php the_field('logo', 'option'); ?>