• Resolved oliverlister

    (@oliverlister)


    Hi all,

    I’m struggling to retrieve values from my ACF custom fields in a new custom PHP pattern I’ve created for my theme. I have a custom field with the slug ‘test’, and I’m trying to retrieve it in the pattern’s code using a ‘get_field’ function.

    I’ve been adding this pattern to a custom post type (made using CPT UI) called ‘work’, and only a blank paragraph box has been showing.

    Any ideas? I don’t have ACF Pro (if that’s required in this instance..)

    <?php
    /**
    * Title: Credits List
    * Slug: squeake/credits-list
    * Categories: text
    * Description: A credit list for a piece of work.
    */
    ?>
    <!-- wp:group {"align":"wide","layout":{"type":"constrained"}} -->
    <div class="wp-block-group alignwide">
    <!-- wp:paragraph {"align":"center","style":{"typography":{"lineHeight":"1"}},"fontSize":"max-23"} -->
    <p>
    <?php
    $text = get_field('test');
    echo $text;
    ?>
    </p>
    <!-- /wp:paragraph -->
    </div>
    <!-- /wp:group -->
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Help retrieving values from ACF custom fields in custom PHP Theme Pattern’ is closed to new replies.