Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用循环获取特定帖子,以填写站点的特定区域_Php_Wordpress - Fatal编程技术网

Php 使用循环获取特定帖子,以填写站点的特定区域

Php 使用循环获取特定帖子,以填写站点的特定区域,php,wordpress,Php,Wordpress,是否可以使用循环来查询特定帖子,并在我的页面上显示帖子内容、标题和自定义字段 我的想法是: if (have_posts() && the_post().id == 66) : while (have_posts()) : the_post(); 听起来您需要使用query\u posts()p=post\u id(1) 所以如果我想显示ID为66的帖子,它应该是这样的('p=66')? <?php query_posts('p=1'); ?> <?php

是否可以使用循环来查询特定帖子,并在我的页面上显示帖子内容、标题和自定义字段

我的想法是:

if (have_posts() && the_post().id == 66) : while (have_posts()) : the_post();

听起来您需要使用
query\u posts()
p=post\u id(1)


所以如果我想显示ID为66的帖子,它应该是这样的('p=66')?
<?php query_posts('p=1'); ?> 
<?php while (have_posts()) : the_post(); ?>
     <?php the_title(); ?>
     <?php the_content(); ?>
<?php endwhile; ?>