Wordpress/워드프레스 노하우
wp_query 현재 포스트 제외하는 방법
매의눈.
2017. 10. 17. 17:57
<?php $currentID = get_the_ID(); $my_query = new WP_Query( array('post__not_in' => array($currentID)));
while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h2> <?php the_content(); ?> <?php endwhile; ?>
post__not_in 을 통해 현재 포스트의 id를 제외시켜버리면 된다.