colorkid2016-10-05 10:47:42
colorkid, 2016-10-05 10:47:42

Advanced Custom Fields is not displayed in the site header. Why?

Hello. I can't display Advanced Custom Fields in the site header. What am I not doing there?
I want to display the phone number in the header and be able to change it from the admin panel.
What I did:
1. - Created a group of fields
2. - Created a field, type text, label Phone, name telumber.
3. - Default value (812)984-02-56
4. - Location - display by post type, both on page and post.
5. - Inserted <?php the_field('telumber'); into the header; ?>
But nothing is displayed. Tell me what am I doing wrong?
header.php file -

<?php wp_title('"', true, 'right'); ?> <?php bloginfo('name'); ?>
<?php wp_head(); ?>
Natural cosmetics Happy life
<?php the_field('telumber'); ?>
<? wp_nav_menu(array('menu' => 'top-menu', 'menu_class' => 'main-menu')); ?>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Denis Yanchevsky, 2016-10-05

Advanced Custom Fields binds fields to specific posts or pages, so you can try to fill in this field, for example, for the main page and display it in the header.php template, specifying the ID of this page.
Replace 15 with your page ID.

WQP, 2016-10-05

Install this https://github.com/wp-premium/advanced-custom-fiel...
Next in fonctions.php we insert

/* Добавляем настройки шаблона */
if( function_exists('acf_add_options_page') ) {

    'page_title' 	=> 'Настройки сайта',
    'menu_title'	=> 'Настройки сайта',
    'menu_slug' 	=> 'theme-general-settings',
    'capability'	=> 'edit_posts',
    'redirect'		=> false

  /* Это если нужна ещё одна страница с опциями
    'page_title' 	=> 'Настройка блоков',
    'menu_title'	=> 'Настройка блоков',
    'parent_slug'	=> 'theme-general-settings',

Next, make a Location page with options (at the very bottom). And now on every page call the_field('telumber', 'option')

Alexey Romanov, 2016-10-08

You need to create either an options page, or, as Denis wrote, you need to explicitly specify the ID of the page from which the field is taken.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question