如何使用标题查询wordpress页面内容

时间:2012-08-22 10:54:16

标签: wordpress

我有一个代码片段,它将回显特定页面的内容,

$id = 123;
$post = get_page($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;

如何插入指定页面的h1标题标签?

2 个答案:

答案 0 :(得分:0)

我不确定我理解你的问题。如果您要在h1标签中显示帖子标题,请尝试以下操作:

<?php
$id=123;
$post = get_page($id);
echo '<h1>' . $post->post_title . '</h1>
?>

答案 1 :(得分:0)

<?php
   echo '<pre>';
   $page_id = 107;
   $page_data = get_page( $page_id );
   echo '<h3>'. $page_data->post_title .'</h3>';
   echo apply_filters('the_content', $page_data->post_content); 
 ?>
相关问题