douya7282 2016-03-22 19:41
浏览 28
已采纳

儿童wordpress主题打破了最后一个类别页面上的网站结构

I am using a child theme I created based off of the Wordpress 2016 theme and I have a category page with a lot of posts to where it creates pagination (because I have only 10 posts per page show) everything works fine until you get to the last few pages and the site begins to break.

I have tried changing the amount of posts you get per page from 5 to 10 and it doesn't seem to change the fact that the last few pages get messed up.

Now I created a custom archive page where I altered the code to display the featured image and excerpt only instead of the whole post.

Here is the code from the archive.php file:

get_header('MBH-cat'); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">
<div id="city-headlines"><h1><?php
foreach((get_the_category()) as $category) { 
echo $category->cat_name . ' '; 
} 
?></h1></div>
    <div id="MBH-blog-roll-cat"><div id="MBH-blog-roll-pad">
    <?php if ( have_posts() ) : ?>


        <?php
        // Start the Loop.
        while ( have_posts() ) : the_post(); ?>
<h2 style="padding-bottom:14px;"><a href="<?php the_permalink(); ?>" title="<?    php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<?php if ( has_post_thumbnail() ): // check for the featured image ?>
<div class="MBH-excerpt-thumb"><a href="<?php the_permalink(' ') ?>" title="<?    php the_title(); ?>" class="opacity"><?php the_post_thumbnail(); ?></a></div> <!--    echo the featured image-->

<div class="MBH-excerpt-div"><?php
endif;
the_excerpt(); // echo the excerpt
?>
<div class="hr"><hr /></div>
</div>

        <?php
endwhile;
// resets main query
?>
<div style="margin-top:280px;">
<?php
        // Previous/next page navigation.
        the_posts_pagination( array(
            'prev_text'          => __( 'Previous page', 'twentysixteen' ),
            'next_text'          => __( 'Next page', 'twentysixteen' ),
            'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
        ) );

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

    endif;
    ?></div>
</div>
    </main><!-- .site-main -->
    </div><!-- .content-area -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
  • 写回答

1条回答 默认 最新

  • dsavz66262 2016-03-22 23:04
    关注

    also, should the:

    <div class="MBH-excerpt-div">
    

    come before the:

    <div class="MBH-excerpt-div">
    

    ?

    Like:

    <div id="primary" class="content-area">
    
    <main id="main" class="site-main" role="main">
    
        <div id="city-headlines">
        <h1>
         <?php
            foreach((get_the_category()) as $category) { 
                echo $category->cat_name . ' '; 
            } 
         ?>
        </h1>
        </div>
    
        <div id="MBH-blog-roll-cat"><div id="MBH-blog-roll-pad">
            <?php if ( have_posts() ) : ?>
    
             <?php
                // Start the Loop.
                while ( have_posts() ) : the_post(); ?>
    
                    <h2 style="padding-bottom:14px;"><a href="<?php the_permalink(); ?>" title="<? php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                    <?php if ( has_post_thumbnail() ): // check for the featured image ?>
                     <div class="MBH-excerpt-thumb">
                       <a href="<?php the_permalink(' ') ?>" title="<? php the_title(); ?>" class="opacity">
                         <?php the_post_thumbnail(); ?>
                       </a>
                     </div>
            <?php endif; ?>
                    <div class="MBH-excerpt-div"> 
                        <?php the_excerpt(); ?>
                        <div class="hr">
                            <hr>
                        </div>
                    </div>
    
                <?php endwhile;
                // resets main query
                ?>
    
    
        </div>
    
            <div style="margin-top:280px;">
                        <?php
                                // Previous/next page navigation.
                                the_posts_pagination( array(
                                  'prev_text'          => __( 'Previous page', 'twentysixteen' ),
                                  'next_text'          => __( 'Next page', 'twentysixteen' ),
                                  'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
                                ) );
            echo '</div>';
    
            // If no content, include the "No posts found" template.
             else :
                 get_template_part( 'template-parts/content', 'none' );
    
             endif; ?>  
    
    </main><!-- .site-main -->
    

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题