Your code looks correct, however,
query_posts is used to modify the main query of the post/page you’re on. You’ll probably want to use
get_posts instead. The rest remains the same:
$args = array( 'post_type' => 'post', 'cat' => 399, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'organization_type', 'value' => 'socialbusiness', ) ) ); ?> <?php $social_businesses = get_posts( $args ); if ( $social_businesses ): ?> <?php foreach ( $social_businesses as $sb ): ?> <a href="<?php echo get_permalink( $sb->ID ); ?>"><?php echo get_the_title( $sb->ID ); ?></a><br> <?php endforeach; ?> <?php endif; ?>
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!
© 2023 Advanced Custom Fields.