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