很多使用WORDPRESS程序建网站的同学都苦于WP程序的分类目录的属性太少了,只有分类的标题,别名,描述。不能像文章模板里可以调用wordpress自定义栏目,而分类目录下的其它属性却很难自定义。

为了让我们更好的利用wordpress程序做出需要的网站功能效果,学做网站论坛分享一下如何给分类目录添加自定义的META属性。
require_once( dirname(__FILE__).'/category_field.php' );
<?php
// 取出当前分类 id: $categories[0]->term_id
$categories = get_the_category();
$term_id = $categories[0]->term_id;
$cat_name = $categories[0]->name;
?>
<div class="phone”>
<div class="p1"><?php echo get_option('cat-tel-'.$term_id);?></div>
<div class="p2"><a href="<?php echo get_option('cat-url-'.$term_id);?> " target="_blank”><?php echo $cat_name;?></a></div>
</div>