如何:将页面内容填充到 WordPress 中的另一个页面

How to : Populate Content of Page to another page in WordPress

我正在为 WordPress 选项面板使用 OptionTree,我正在获取页面 ID,并使用该页面 ID 将页面内容填充到另一个页面。这是我的代码:

<?php 
$test_input = ot_get_option( 'for_myapp_features' );
?>
<?php $the_query = new WP_Query( 'page_id=$test_input' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post();  ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php endwhile;?>

任何帮助都会有所帮助。

如果您想显示该页面的内容,请在您的 while 循环中添加 the_content()the_content() 将显示页面的内容。我还会在 endwhile 之后添加查询重置 wp_reset_query();,以将全局 post 数据恢复到原始查询。

You can use get_post_field and get_the_title() to get content and title.

$test_input = ot_get_option('for_myapp_features');

echo get_post_field('post_title', $test_input); // to get the title
//or
//echo get_the_title($test_input); // to get the title
echo get_post_field('post_content', $test_input); //to get the content

希望对您有所帮助!