最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
WordPress 获取评论与当前分类的根分类id函数
时间:2022-06-25 19:17:31 编辑:袖梨 来源:一聚教程网
1.在模版中加入recent_comments.php文件,其代码如下:
| 代码如下 | 复制代码 |
|
$comments = get_comments('number=10&status=approve'); Say: } if($true_comment_count == 5) break; endforeach; ?> |
|
2.然后在sidebar.php你想要显示的位置中插入:
| 代码如下 | 复制代码 |
|
include (TEMPLATEPATH . '/recent_comments.php'); ?> |
|
WordPress获取当前分类的根分类id函数
只有自己动手了,后来使用了以下两个方法解决了问题!
function get_category_root_id($cat)
代码如下
复制代码
{
$this_category = get_category($cat); // 取得当前分类
while($this_category->category_parent) // 若当前分类有上级分类时,循环
{
$this_category = get_category($this_category->category_parent); // 将当前分类设为上级分类(往上爬)
}
return $this_category->term_id; // 返回根分类的id号
}
function fengzx_get_category_ID() {
$category = get_the_category();
return $category[0]->cat_ID;
}
相关文章
- 新仙魔九界勾玉有哪些获取途径 10-24
- 星球重启食物怎么获得 10-24
- 小小梦魇尖刺头人在哪 10-24
- 辉烬羽尘有哪些获取途径 10-24
- 二重螺旋限定武器如何获取 10-24
- 伙伴弹途青蛇技能有什么效果 10-24