代码用于single-product.php
. 我可以在页面上列出所有产品,但我想列出所有带有slug标题的帖子。
<?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: 三星(slug/类别)Galaxy note 5