Wordpress:如何在News Pro Genesis中将页面设置为主页

时间:2015-02-20 18:47:47

标签: wordpress genesis

我有Genesis框架,我将自定义页面设置为首页时遇到问题,

设置为主页时,所有帖子都不显示。

但是当它作为页面访问时我会看到所有帖子。

问题在哪里?

<div class="content-sidebar-wrap">

<main class="content" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">

<div id="content_box">
                        <?php   
                        $i=0;                   
                        wp_reset_query();
                        query_posts('posts_per_page=10&post_type=post');
                        if(have_posts() ) :
                        while(have_posts()) : the_post();
                        ?>  

<article class="latestPost excerpt <? if($i%2==0){?> first <? } ?>" itemscope="" itemtype="http://schema.org/BlogPosting">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" id="featured-thumbnail">
<div class="featured-thumbnail">
                                    <?php                   
                                    if ( has_post_thumbnail() ) {
                                        the_post_thumbnail(array('370','297'));
                                    }
                                    ?>
</div>
</a>
<header>
<h2 class="title front-view-title" itemprop="headline">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<?php the_title(); ?>
</a>
</h2>
</header>
</article>

                        <?php
                        $i++;
                        endwhile;endif;
                        wp_reset_query();
                        ?>  

</div>

<?php add_action( 'genesis_after_content', 'genesis_get_sidebar' ); ?>

</main>

</div>

1 个答案:

答案 0 :(得分:0)

如果您使用自定义页面,则在编辑页面admin上有模板选择并选择博客模板,或者您可以将自定义模板用于自定义博客内容。

我认为在循环之前有一个if语句,如is_front_page()或is_home()。如果没有,请尝试以下代码。

自定义页面模板的示例是

/* Template Name: Custom page template */   
add_action( 'genesis_meta', 'custom_page_template_function' );
function custom_page_template_function(){ 
    remove_action( 'genesis_loop', 'genesis_do_loop' ); 
    add_action( 'genesis_loop', 'custom_do_loop' );   
}  
function custom_do_loop(){ 
 // content or custom query post 
} 
genesis();