Support

Account

Home Forums Front-end Issues fields are not displaying in custom Query in an ACF Block

Solving

fields are not displaying in custom Query in an ACF Block

  • I’m trying to query some posts in an ACF Block. The same code is working properly used on the single.php, but even if I use exactly the same code provided under query-posts-custom-fields it just displays the the_title(), the_content()… but nothing from acf.

    Where does it stuck, why is it not working within a block?

    Thanks for any help 🙂

    <?php
        $args =  array(
            'orderby' => 'menu_order',
            'order' => 'ASC',
            'post_status' => 'publish',
            'post_type' => 'post',
        ) ;
         
    // query
    $the_query = new WP_Query( $args );
    if( $the_query->have_posts() ): 
        while( $the_query->have_posts() ) : $the_query->the_post(); 
            $veranstaltung = get_field('anzeigeorte');
            if( get_field('veranstaltung') && $veranstaltung && in_array('aktuelles', $veranstaltung) ) { ?>
                <a href="<?php the_permalink(); ?>" class="preview veranstaltung-preview">
                    <h3><?php the_title(); ?></h3>
                    <p class="date"><?php the_field( 'datum'); ?></p>
                    <p><?php the_field( 'kurzbeschreibung'); ?></p>
                </a>
            <?php } 
    
            elseif ( ! get_field('veranstaltung') ) { ?>
            <a href="<?php the_permalink(); ?>" class="preview post-preview">
                <h3><?php the_title(); ?></h3>
                <?php the_excerpt(); ?> 
            </a>
        <?php }
    	endwhile; 
    endif; ?>
    
    <?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>
  • The same code is working properly used on the single

  • I’m wondering why my ACF fields are not showing up in my gatsby app using the gatsby-source-graphql plugin? My ACF fields show up when I use the WP plugin: WP GraphiQL, but not when I run my gatsby app. Can I only import ACF fields using gatsby-source-wordpress??? Everything else seems to show up. I have a custom post type that I’m using no problem, but ACF fields are the issue. Any help would be amazing, Thanks, Spencer

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

You must be logged in to reply to this topic.