1
我需要呼应职位类别链接,所以这里是我的查询:获取类别链接WordPress的
<?php
$args=array(
'cat' => 3,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 3,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
....SOME HTML....
<?php
endwhile;
}
wp_reset_query();
?>
和底部,我需要点击“查看所有文章”,它应该重定向到后子类别列表。
获取帖子的ID并使用函数get_the_category(post_id)获取类别,帖子可能属于多个类别。从get_the_category()返回的对象中检索类别id,现在使用函数get_category_link(cat_id)获取类别链接 – WisdmLabs