WordPress get_post_meta not work in loop
-
Hello,
I can not get_post_meta to work inside a loop. Here is the code:<div class="container"> <div class="row"> <!-- Query Post Portfolio--> <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=9' . '&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div class="col-lg-4 <?php // Retrieves the stored value from the database $meta_value = get_post_meta( get_the_ID() , 'meta-select', true ); // Checks and displays the retrieved value if( !empty( $meta_value ) ) { echo $meta_value; } ?> col-xs-12" data-aos="fade-up" data-aos-duration="1500" data-aos-easing="ease-out-cubic"> <?php get_template_part( 'template-parts/content','post-portfolio-all-standar', get_post_type() );?> </div> <?php endwhile; wp_reset_postdata(); ?> </div> </div>
where am I wrong? I checked the output, and the function always prints the first option, and the other options even if selected are not printed. Thank you so much
- The topic ‘WordPress get_post_meta not work in loop’ is closed to new replies.