Home › Forums › Front-end Issues › 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(). ?>
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
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.