admin管理员组文章数量:1122846
I'm a beginner developer so I'm sorry if I've made some obvious mistake, but I simply don't get why my loop for posts is not displaying all of my posts, I created 14 test posts and set the Reading options in Wordpress to display latest posts and put the number to 10, however, only 5 posts appear on the first page and when I click on 2nd page in the pagination there's only 1 post and my footer goes all the way up to the end of the post box instead of staying down on the 2nd page.
<?php get_header(); ?>
<div class='containter containter--narrow page-section'>
<?php if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" class='post-item'>
<h2><a class="post-title headline headline-medium" href='<?php the_permalink(); ?>'><?php the_title(); ?></a></h2>
<hr>
<div class='metabox'>Author: <?php the_author_posts_link(); ?> Published on: <?php the_time('d/M/Y'); ?> Categories: <?php echo get_the_category_list(', '); ?></div>
<div class="post-excerpt content">
<?php the_excerpt() ?>
<p><a class='read-more' href="<?php echo get_permalink(the_post()); ?>">Read More »</a></p>
</div>
</article>
<?php endwhile;
endif;
echo paginate_links(); ?>
</div>
<?php get_footer();
?>
I'm a beginner developer so I'm sorry if I've made some obvious mistake, but I simply don't get why my loop for posts is not displaying all of my posts, I created 14 test posts and set the Reading options in Wordpress to display latest posts and put the number to 10, however, only 5 posts appear on the first page and when I click on 2nd page in the pagination there's only 1 post and my footer goes all the way up to the end of the post box instead of staying down on the 2nd page.
<?php get_header(); ?>
<div class='containter containter--narrow page-section'>
<?php if ( have_posts() ) :
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" class='post-item'>
<h2><a class="post-title headline headline-medium" href='<?php the_permalink(); ?>'><?php the_title(); ?></a></h2>
<hr>
<div class='metabox'>Author: <?php the_author_posts_link(); ?> Published on: <?php the_time('d/M/Y'); ?> Categories: <?php echo get_the_category_list(', '); ?></div>
<div class="post-excerpt content">
<?php the_excerpt() ?>
<p><a class='read-more' href="<?php echo get_permalink(the_post()); ?>">Read More »</a></p>
</div>
</article>
<?php endwhile;
endif;
echo paginate_links(); ?>
</div>
<?php get_footer();
?>
Share
Improve this question
asked Apr 3, 2020 at 14:49
AcidBurnAcidBurn
227 bronze badges
5
|
1 Answer
Reset to default 0if anyone else is having the same problem as me, here is the solution. The problem that was causing this was
<?php echo get_permalink(the_post()); ?>
Honestly, I have no idea why I went with this instead of just the_permalink() , was having a problem with my read more button it was sending me to a different post than the post that was displaying, after removing get_permalink(the_post)) and replacing it with the_permalink() the problem was solved for both the read more button and for my previous problem. I can see all of the posts displayed on the website now.
本文标签: Wordpress posts loop not displaying all posts on blog
版权声明:本文标题:Wordpress posts loop not displaying all posts on blog 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736292686a1928987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
query_posts
which is a terrible function you should never use. Avoid it like the plague. – Tom J Nowell ♦ Commented Apr 3, 2020 at 15:56query_posts
anywhere in your code? Never use that function, it will break your pagination and double the number of queries on your page. As for your code, under normal circumstances this should work as is, but plugins and filters can interfere. I also don't understand the reference to your footer, there is no footer code in your question, and I don't see how it impacts the pagination – Tom J Nowell ♦ Commented Apr 3, 2020 at 15:57