开发者

wordpress templating get the content of parent page

how do i get the_content for the parent page when templating in WP?

(pages-only structure)

preferably wo plugins o开发者_JAVA技巧r sql.

regards, /t


<?php $page = get_page(); // gets current page ID
      $parentID = $page['post_parent']; // gets parent ID, if there is one
      if($parentID != '0') {
        $parentPage = get_page($parentID);
        $parentContent = $parentPage['post_content']; // gets raw content
        $parentContent = apply_filters('the_content', $parentContent); // filters content
      } ?>

That's one way to do it.


$parent = get_post($post->post_parent);

then you can do

$parentContent = $parent->post_content

FYI, get_page() wraps get_post()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜