Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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_Loops - Fatal编程技术网

在主页wordpress上显示特定页面的特色图片和摘录

在主页wordpress上显示特定页面的特色图片和摘录,wordpress,loops,Wordpress,Loops,我想在我的主页上显示ie.ABOUT页面的特色图片和摘录。有没有可能只对页面而不是帖子这样做?同时找到了摘录的答案,现在我只需要特色图片 将新函数添加到functions.php: //Display page excerpts add_action( 'init', 'my_add_excerpts_to_pages' ); function my_add_excerpts_to_pages() { add_post_type_support( 'page', 'excerpt' )

我想在我的主页上显示ie.ABOUT页面的特色图片和摘录。有没有可能只对页面而不是帖子这样做?

同时找到了摘录的答案,现在我只需要特色图片

将新函数添加到functions.php:

//Display page excerpts
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
     add_post_type_support( 'page', 'excerpt' );
}
并调用FrontPage.php>

<?php echo get_the_excerpt(); ?>

                                <?php 
                                    query_posts("page_id=2");
                                    while ( have_posts() ) : the_post()
                                ?>
                                    <h1>Why US?</h1>
                                    <?php the_excerpt(); ?>

                                <?php
                                    endwhile; 
                                    wp_reset_query();
                            ?> 

对于特色图像,您需要: 1-要修改您的功能,还要添加缩略图支持

add_action( 'init', 'my_extend-page_functions' );
function my_extend-page_functions() {
     add_post_type_support( 'page', array('excerpt', 'thumbnail' );
}
在codex页面上查看您可以添加的所有内容

2-在首页上,您可以使用\u post\u缩略图

我设法让特色图片显示出来,但我添加了一些不需要的内容,就像之前的摘录一样,我正在从博客中获取另一篇文章的摘录:/这是我的代码的样子,任何需要的建议通常都不应触及主查询,而应创建二次循环