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

时间:2015-01-03 20:09:56

标签: wordpress loops

我想显示特色图片和ie的摘录。关于我主页上的页面。是否可以使用仅非帖子的页面来执行此操作?

2 个答案:

答案 0 :(得分:0)

在此期间找到答案的摘录,现在我只需要特色图片

向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' );
}

并在front-page.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 :(得分:0)

对于精选图片,您需要: 1 - 修改你的功能,添加缩略图支持

add_action( 'init', 'my_extend-page_functions' );
function my_extend-page_functions() {
     add_post_type_support( 'page', array('excerpt', 'thumbnail' );
}

(请查看您可以添加http://codex.wordpress.org/Function_Reference/add_post_type_support

的所有代码页 首页上的

2-,您可以使用the_post_thumbnail() http://codex.wordpress.org/Function_Reference/the_post_thumbnail

相关问题