Home Forums Feature Requests Get custom field inside query loop block Reply To: Get custom field inside query loop block

  • Just popping in here to say that a dedicated ACF field block DOES work! @uniondesign Maybe when you posted this they did not, but creating a dedicated custom block to output an ACF field inside a Query Loop block does work just fine.

    Here is some example code:

    function register_acf_block() {
        // Check function exists.
        if( function_exists('acf_register_block_type') ) {
            // Register a custom block.
                'name'              => 'acf_contact_title',
                'title'             => __('Contact Title'),
                'description'       => __('A custom block to display the Contact title (ACF field) for Team Members inside the Query Loop block.'),
                'render_callback'   => 'render_acf_block',
                'category'          => 'formatting',
                'icon'              => 'admin-comments',
                'keywords'          => array( 'contact', 'title' ),
    add_action('acf/init', 'register_acf_block');
    function render_acf_block( $block ) {
        // Get the post ID
        $post_id = get_the_ID();
        // Get the contact title ACF field
        $contact_title = get_field('contact_title', $post_id);
        // Display the contact title
        echo '<p>' . $contact_title . '</p>';

    It may be a little clunky but you can put all the “field blocks” into their own category so it doesn’t get confusing for Editor users.