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
在Wordpress中显示分类文章的摘录_Wordpress - Fatal编程技术网

在Wordpress中显示分类文章的摘录

在Wordpress中显示分类文章的摘录,wordpress,Wordpress,我试图在一个推荐滑块中显示一个类别内帖子的摘录。我有上面的代码,我正在使用高级自定义字段自定义帖子,以显示头像、姓名和引用。我将代码添加到footer.php中,其中存在滑块,但出现的帖子是“未分类”部分中的帖子。知道我做错了什么吗 <?php $posts = query_posts('cat=testimonials&showposts=1'); foreach($posts as $post) { ?> <?php the_excerpt(); ?> <

我试图在一个推荐滑块中显示一个类别内帖子的摘录。我有上面的代码,我正在使用高级自定义字段自定义帖子,以显示头像、姓名和引用。我将代码添加到footer.php中,其中存在滑块,但出现的帖子是“未分类”部分中的帖子。知道我做错了什么吗

<?php $posts = query_posts('cat=testimonials&showposts=1'); foreach($posts as $post) { ?>
<?php the_excerpt(); ?>
<?php } ?>

查询帖子('cat=推荐和展示帖子=1')

或尝试

查询帖子('cat=CATID&showposts=1'); CATID>>替换为您的cat id

更新的答案

然后尝试使用get\u post查询\u post

global $post;
$args = array( 'numberposts' => -1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ){ echo $post->post_excerpt; }

可能对您有帮助…

尝试了以下操作,但没有成功:
code
    global $post;
    $args = array( 'numberposts' => -1, 'category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ){ echo $post->post_excerpt; }