For example, there are 2 parent class A, B
Subcategories of 4 were A-1, A-2, B-1, B-2
I want to get the parent category name in the sub-category article: What should A or B do?
Reply content:
For example, there are 2 parent class A, B
Subcategories of 4 were A-1, A-2, B-1, B-2
I want to get the parent category name in the sub-category article: What should A or B do?
$this->categories;You can output all current classifications, and then you can go to the database to read them yourself. Look forward to a better approach.
//获取顶级分类function topcategory($category) { $db = Typecho_Db::get(); $prefix = $db->getPrefix(); $rs = $db->fetchRow($db->select()->from($prefix.'metas')->where('slug = ?', $category)->limit(1)); if($rs['parent']==0){ return $rs['slug']; } else { $rs2 = $db->fetchRow($db->select()->from($prefix.'metas')->where('mid = ?', $rs['parent'])->limit(1)); return $rs2['slug']; }}
See www.sisi321.com
I know that, too.
The problem is I just need to output the parent's name A or b separately