0
我想通过分类标准在Wordpress上的单个文章页面显示相关文章。我使用下面的代码来显示同一类别的帖子,但不是相同的自定义分类。自定义分类,我需要用的是product_cat按分类标准显示相关文章Wordpress
<?php
global $post;
$categories = get_the_category();
$category = $categories[0];
$cat_ID = $category->cat_ID;
$loop = new WP_Query(array('post_type' => 'product','post__not_in' => array($post->ID), 'category' => $cat_ID)); ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<?php the_title('<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h2>'); ?>
<?php endwhile; ?>
如何调整当前的代码?