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()
精彩评论