代码为
$args=array(
'post_type' => "product",
'post_status' => 'publish',
'taxonomy' => 'products_category',
'order' =>'ASC',
'number' => '',
'hide_empty' => 0 );
$my_query = new WP_Query( $args );
echo '<ul class="product_category">';
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
echo '<li>';
echo '<a href='. the_permalink() .'>';
echo the_title();
echo '</a></li>';
endwhile;
}
echo '</ul>';wp_reset_query();
我想显示产品帖子类型的帖子。文章是正确的,但文章的链接没有进入一个href标签。
使用get_permalink()代替the_permalink();
$args=array(
'post_type' => "product",
'post_status' => 'publish',
'taxonomy' => 'products_category',
'order' =>'ASC',
'number' => '',
'hide_empty' => 0 );
$my_query = new WP_Query( $args );
echo '<ul class="product_category">';
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
echo '<li>';
echo '<a href='. get_permalink() .'>';
the_title();
echo '</a></li>';
endwhile;
}
echo '</ul>';wp_reset_query();
用get_permalink()
代替the_permalink()
,如果问题仍然存在,试试$my_query->get_permalink()