代码示例:
$page_id = 116; // 123 should be replaced with a specific Page\'s id from your site, which you can find by mousing over the link to edit that Page on the Manage Pages admin page. The id will be embedded in the query string of the URL, e.g. page.php?action=edit&post=123.
$page_data = get_page( $page_id ); // You must pass in a variable to the get_page function. If you pass in a value (e.g. get_page ( 123 ); ), Wordpress will generate an error.
$content = apply_filters(\'the_content\', $page_data->post_content); // Get Content and retain Wordpress filters such as paragraph tags. Origin from: http://wordpress.org/support/topic/get_pagepost-and-no-paragraphs-problem
$title = $page_data->post_title; // Get title
echo $title; // Output Content
echo $content; // Output Content
?>
而不是
166
(手动输入),我想检索当前页面的ID。
当我执行$page\\u id=$post->id时,它会检索下面循环的第一篇帖子的标题和内容(这是帖子页面):
<div class="container">
<?php // find all content that has the type of video and then to loop through them. ?>
<?php query_posts(\'showpost\'); ?>
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_front_page() ) { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } else { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>
<div class="entry-content">
<?php the_content(); ?>
<?
php wp_link_pages( array( \'before\' => \'<div class="page-link">\' . __( \'Pages:\', \'twentyten\' ), \'after\' => \'</div>\' ) ); ?>
<?php edit_post_link( __( \'Edit\', \'twentyten\' ), \'<span class="edit-link">\', \'</span>\' ); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php comments_template( \'\', true ); ?>
<?php endwhile; ?>
</div>
我想动态检索当前页面的代码(116)。
实现这一点的代码是什么?