The code is for single-product.php. I can list all products on page but I want to list all posts with slug titles.

$args= array(
    'post_type'      => 'products',
    'order_by'       => 'date',
    'posts_per_page' => -1,
    'post__not_in'   => array( get_the_ID() ),

$wp_query = new WP_Query( $args );

while( $wp_query->have_posts() ) {
    echo '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';


  1. Samsung ->(slug / category)
    • Galaxy note 5
    • Galaxy note 5
  2. Apple ->(slug / category)
    • Iphone7
    • Iphone8
  • What is 'slug title'? – Max Yudin Mar 6 at 11:38
  • i have 3 slugs ( samsung, iphone, lg,....) more slugs will create later.... – Smnc Mar 6 at 11:50

If by "slug title" you mean a taxonomy (e.g. product category), then have a look at the code posted on the accepted answer on Display All Products by Category with WooCommerce It should give you an idea (or even the complete solution) how to get your posts listed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.