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!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN
— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.
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.