0

I create a group field for "contact info" and define to edit it only in Homepage. enter image description here

And it works on Homepage. But if I go to another page of the website, the fields just disappear enter image description here

My code for contact info in header.php is:

        <header>

        <section class="container-top">
            <div class="wrapper">
                <span>
                    <?php the_field( 'telefone_header' ); ?>            
                </span>
                <a href="mailto:<?php the_field( 'email_header' ); ?>">
                    <?php the_field( 'email_header' ); ?>
                </a>

                <?php get_search_form(); ?>
            </div>
        </section>
        <section class="container-header">
            <div class="wrapper">
                <h1>
                    <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="Limpen">
                        <img src="<?php bloginfo( 'template_directory' ); ?>/images/limpen.jpg" alt="Limpen">
                    </a>
                </h1>
                <nav>
                <?php wp_nav_menu ( array (
                        'container' => false,
                        'items_wrap' => '<ul>%3$s</ul>',
                        'walker' => new My_Walker_Nav_Menu()
                    )
                ); ?>
                    <div class="ico-menu"></div>
                </nav>
            </div>
        </section>

    </header>

And for the footer.php is:

<div class="links">
                    <strong>
                        Fale Conosco
                    </strong>
                    <div class="info">
                        <strong>
                            <?php the_field( 'titulo_empresa' ); ?>
                        </strong>
                        <a href="mailto:<?php the_field( 'email_empresa' ); ?>"><?php the_field( 'email_empresa' ); ?></a>
                        <span><?php the_field( 'telefones_empresa' ); ?></span>
                        <address>
                            <?php the_field( 'endereco_empresa' ); ?>
                        </address>
                    </div>
                </div>
2
  • proper place to ask it is ACF support Oct 13, 2016 at 9:52
  • asked there too
    – Luan
    Oct 13, 2016 at 9:53

1 Answer 1

3

You need to add the ID of the page as the second argument.

E.G If your home page has a page ID of 1, you need to do:

the_field('field_name', 1);

See here for more information on the_field.

https://www.advancedcustomfields.com/resources/the_field/

1
  • Thank you Steve! I updated the line of code with the page ID in both (header.php and footer.php) and now it works on all pages.
    – Luan
    Oct 13, 2016 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.