Monday, January 23, 2017

display latest post excluding current post

<?php $args = array(
    'post_type' => 'product',
    'posts_per_page' => -1,
    'post__not_in'   => array( get_queried_object_id() ),
);
$product_latest = new WP_Query( $args ); ?>
<?php while( $product_latest->have_posts() ): $product_latest->the_post(); ?>
<h3><?php the_title(); ?><h3>
<?php the_content(); ?>
<?php endwhile; ?>

No comments:

Post a Comment