WordPress自定义分类

时间:2011-06-13 21:00:39

标签: php wordpress debugging taxonomy

我想知道是否有办法列出当前页面的兄弟姐妹的所有自定义分类法(例如在我的single.php中)?

例如我的分类如下

分类

  • - 古代
  • +++希腊语
  • ///// Plato
  • /////苏格拉底
  • +++ Roman
  • +++ Indian
  • - 经典
  • - 现代

我想创建一个侧栏,列出所有其他具有相同父级的项目(包括其他兄弟姐妹的后代 - 例如“希腊语”页面将列出“罗马”和“印度”。“古代”页面将包括链接到“Ancient>> Greek”,“Ancient>> Roman”,“Ancient>> Indian”,“Classic”和“Modern”Pages。)

这可以通过自定义分类法实现吗?我怎样才能实现它?

谢谢!

*的 修改 *

另外,作为参考,我正在使用以下博客文章,这些文章更详细地介绍了我需要的内容,我只是在根据我在原帖中提到的规范进行定制时遇到了问题:

http://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/

https://github.com/scribu/wp-query-multiple-taxonomies/wiki/Changing-templates

http://scribu.net/wordpress/extending-the-category-walker.html

1 个答案:

答案 0 :(得分:0)

$post = get_post($id); //Get the post id

    if($post->post_parent){ //If it has a parent

        wp_list_pages('child_of='.$post->post_parent . '&exclude='.$id); //List the pages that are children of the parent page, excluding the current one.

    }

这将创建一个页面的所有兄弟姐妹的列表。我有一种感觉,你想要一些略有不同的东西,就像你提到自定义分类法和页面一样。这些自定义帖子类型,类别或页面?如果这对您有用,请告诉我:))