在Twenty Fourteen Wordpress的主页上删除帖子循环并保持分页

时间:2016-08-01 21:55:59

标签: php wordpress

我正在努力保留特色内容,所以只有画廊显示在主页上,所以我试图禁用后循环,我可以很容易地做,但我在删除它时无法保持分页。

这是代码

<?php
    if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
        // Include the featured content template.
        get_template_part( 'featured-content' );
    }
?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

        <?php
            if ( have_posts() ) :
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    /*
                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */
                    get_template_part( 'content', get_post_format() );

                endwhile;
                // Previous/next post navigation.
                twentyfourteen_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>

        </div><!-- #content -->
    </div><!-- #primary -->

我也会尝试在CSS

中进行
.home .post-37401 {
display: none;
}

这是删除特定帖子,但我想尝试删除所有帖子而不会弄乱特色图库

1 个答案:

答案 0 :(得分:0)

这对任何需要这个的人都有用......

<?php
    if ( is_front_page() && twentyfourteen_has_featured_posts() ) {
        // Include the featured content template.
        get_template_part( 'featured-content' );
    }
?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

        <?php
            if ( have_posts() ) :
                // Start the Loop.
                while ( have_posts() ) : the_post();

                    /*
                     * Include the post format-specific template for the content. If you want to
                     * use this in a child theme, then include a file called called content-___.php
                     * (where ___ is the post format) and that will be used instead.
                     */
$xpaged = (get_query_var('paged')) ? get_query_var('paged') : 1;
global $paged;

if ( $paged  > 1 ) {                    
get_template_part( 'content', get_post_format() );
}
                endwhile;
                // Previous/next post navigation.
                twentyfourteen_paging_nav();

            else :
                // If no content, include the "No posts found" template.
                get_template_part( 'content', 'none' );

            endif;
        ?>

        </div><!-- #content -->
    </div><!-- #primary -->