最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
WordPress 获取评论与当前分类的根分类id函数
时间:2013-05-14 编辑:简简单单 来源:一聚教程网
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;
}
-
上一个: js 去除重复数组并排序实现代码
-
下一个: jquery实现图片左右滚动插件
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31