2011-06-13 74 views
1

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

例如我的分类如下:

分类

  • - 古
  • +++希腊
  • /////柏拉图
  • /////苏格拉底
  • +++罗马
  • +++印度
  • - 经典
  • - 现代

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

这可能与自定义分类法?我怎样才能实现它?

谢谢!

* 编辑 *

此外,仅供参考,我用下面的博客文章,其给出更详细了解我需要什么,我只是我有麻烦它定制的规范工作,我在我原来的文章中提到:

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

回答

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. 

    } 

这将创建一个页面的所有兄弟的列表。我有一种感觉,你想要稍微有点不同,因为你提到自定义分类法和页面。这些自定义帖子类型,类别或页面?让我知道如果这对你有用:)

+0

感谢万迈克尔!我在寻找的是“定制分类”结构中的兄弟姐妹列表,它与页面/类别不同,虽然层次结构使用类似的WordPress机制,但实际代码会有所不同。有任何想法吗? – Brian 2011-06-14 22:02:06

+0

此外,作为参考,我正在处理以下博客文章,其中详细介绍了我需要的内容,我只是无法将其定制为我在原始文章中提到的规范:http://net.tutsplus。 com/tutorials/wordpress/introduction-wordpress-3-custom-taxonomies /,https://github.com/scribu/wp-query-multiple-taxonomies/wiki/Changing-templates,http://scribu.net/wordpress /extending-the-category-walker.html – Brian 2011-06-14 22:48:02

相关问题