平时大家关注的Wordpress日志的调用更多一些,比如相关日志、随机日志、热门日志等,此文分享一下Wordpress各页面调用:
当前页面的父级页面调用:
<?php
if($post->post_parent) {
$parent_title = get_the_title($post->post_parent);
echo $parent_title;
} else {
wp_title('');
}
?>
当前页面的同级页面调用:
<?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>';
}
?>
可以自己灵活变化着用。
评论