The code is for single-product.php
.
I can list all products on page but I want to list all posts with slug titles.
<?php
$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() ) {
$wp_query->the_post();
echo '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
}
Example:
The code is for single-product.php
.
I can list all products on page but I want to list all posts with slug titles.
<?php
$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() ) {
$wp_query->the_post();
echo '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
}
Example:
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.