我试过了,它实际上显示的是当前页面内容而不是父内容:
<?php
$my_postid = 3105;
$content_post = get_post($my_postid);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
echo $content;
?>
并且还尝试了以下方法,但我收到警告:
Warning: Missing argument 1 for get_page(), called in:
代码:
<?php
$page = get_page();
$parentID = $page['post_parent'];
if($parentID != '0') {
$parentPage = get_page($parentID);
$parentContent = $parentPage['post_content'];
$parentContent = apply_filters('the_content', $parentContent);
echo $parentContent;
}
?>