首页 » WordPress » 显示同个父页面的其他子页面的链接

显示同个父页面的其他子页面的链接

July 18th, 2008 Denis

假设以下情况,有一个父页面,然后它有一些子页面。当你打开父页面的时候,你想在 sidebar 显示它的子页面的链接。 当你打开子页面链接的时候,你还是想要显示同样一组链接。但问题是,你现在想显示的是相同父页面的其他子页面。你不能通过一个简单函数就能解决这个问题。下面是详细解决方法:

<?php
if($post->post_parent)
    $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
    $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) {
    echo '<ul>';
        echo $children;
    echo '</ul>';
} ?>

Via Simple Trick: Displaying Links to other Child Pages from the Same Parent

作者:Denis
原文链接:显示同个父页面的其他子页面的链接

标签:

分享到 Twitter 分享到 Twitter Delicious 收藏到 Delicious 分享到 Google Reader 分享到 Google Reader 分享到 FriendFeed 分享到 FriendFeed

3 条评论 添加你的评论

发表评论

你必须 登陆 之后才能留言。你可以使用以下方式快速登陆我爱水煮鱼:

你也可选择直接在本站 注册


我最喜欢的 WordPress 插件:Top 10 独立的 Baby 博客


赞助商

 (mt) Media Temple 长期承接 WordPress 项目 WordPress主机合租 用网页模板,当然要选TemplateMonster China 免費資源網路社群 freegroup.org http://p6p9.com/ 在我爱水煮鱼投放广告位

本站推荐

快速导航