Support

Account

Home Forums Front-end Issues Problem with get_fields

Solving

Problem with get_fields

  • I am trying to pull a field with get_field on my Blog page (index.php). The code I’m using works on other templates, but not the index.php file?

    <?php $blog_header = get_field(‘blog_header’); ?>
    <div class=”hero” style=”background-image:url(<?php print “$blog_header”; ?>)” data-sr=”enter bottom”>

  • Its better to create an options page for this and receive you values via get_field( 'field_slug', 'option' );

    On your index.php you’re receiving all your posts, so the index.php has no post id. You can create an page template (with custom post query for your posts) and working with this, but an option page is easier for this.

  • Thanks Kevin, I’ll give that a try.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Problem with get_fields’ is closed to new replies.