Home › Forums › General Issues › Query posts based on a select list meta › Reply To: Query posts based on a select list meta
I succeeded to have a beginning of resukt with :
function sidebar_related() {
$type = get_field( "themes", get_the_ID() );
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'themes',
'value' => $type
)
),
);
$my_posts = new WP_Query($args); ?>
<?php if ( $my_posts->have_posts() ) : while ( $my_posts->have_posts() ) : $my_posts->the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title() ;?></a>
<?php endwhile; else : ?>
<p><?php _e( 'No Posts To Display.' ); ?></p>
<?php endif;
}
add_shortcode('related-terms', 'sidebar_related');
Is it possible not to display in the list the title of the current post ?
Thank you !
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.