:WordPress 获取当前文章ID的方法
if (!is_page() && !is_home()){
$catsy = get_the_category(); $myCat = $catsy[0]->cat_ID; $currentcategory = '¤t_category='.$myCat;
}
wp_list_categories('hierarchical=1&use_desc_for_title=0&exclude=12&depth=1&orderby=id&title_li='.$currentcategory);
?>
第四种:
[代码]php代码:
<?php
foreach((get_the_category()) as $category) {
echo $category->cat_ID . ''; //当前文章的分类的ID