子 wordpress 主题破坏了最后类别页面上的网站结构
Child wordpress theme breaks site structure on last category pages
我正在使用基于 Wordpress 2016 主题创建的子主题,我有一个类别页面,其中有很多 post 到它创建分页的位置(因为我只有 10 posts 每页显示)一切正常,直到您到达最后几页并且网站开始崩溃。
我已经尝试将每页获得的 post 的数量从 5 更改为 10,但它似乎并没有改变最后几页乱七八糟的事实。
现在我创建了一个自定义存档页面,我在其中更改了代码以仅显示特色图片和摘录而不是整个 post。
这是 archive.php 文件中的代码:
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(); ?>
另外,应该:
<div class="MBH-excerpt-div">
先于:
<div class="MBH-excerpt-div">
?
喜欢:
<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 -->
我正在使用基于 Wordpress 2016 主题创建的子主题,我有一个类别页面,其中有很多 post 到它创建分页的位置(因为我只有 10 posts 每页显示)一切正常,直到您到达最后几页并且网站开始崩溃。
我已经尝试将每页获得的 post 的数量从 5 更改为 10,但它似乎并没有改变最后几页乱七八糟的事实。
现在我创建了一个自定义存档页面,我在其中更改了代码以仅显示特色图片和摘录而不是整个 post。
这是 archive.php 文件中的代码:
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(); ?>
另外,应该:
<div class="MBH-excerpt-div">
先于:
<div class="MBH-excerpt-div">
?
喜欢:
<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 -->