[英]styling wordpress posts loop
I've been trying to edit the code for the blog page of wordpress. 我一直在尝试编辑wordpress博客页面的代码。 I have 14 posts and I've set the page to display 5 posts per page. 我有14个帖子,我将页面设置为每页显示5个帖子。 However, it's not working. 但是,它不起作用。 The first 5 posts displayed just fine, but when you click on "Older Entries", there's nothing. 前5个帖子显示得很好,但是当您单击“旧条目”时,没有任何显示。 I was trying to make it display 5 posts per page. 我试图使其每页显示5个帖子。 Here's the code: 这是代码:
<div id="blog_content_row">
<div class="container">
<div class="row">
<div class="article editable">
<div>
<?php
// Title on some archive views
get_template_part( 'parts/title', 'archive');
// display featured sometimes
if (!is_paged() && is_home()) {
$original_query = $wp_query;
$wp_query = null;
$wp_query = new WP_Query(array('posts_per_page' => 5, 'meta_key' => 'featured_post', 'meta_value' => 'true', 'post__not_in' => get_option( 'sticky_posts' )));
if ($wp_query->have_posts()) {
} else {
$wp_query = null;
$wp_query = new WP_Query(array('posts_per_page' => 5, 'post__not_in' => get_option( 'sticky_posts' )));
}
if (have_posts()) {
while (have_posts()) {
the_post();
$nimbus_feature_id = $post->ID;
get_template_part( 'parts/blog', 'featured');
}
} else {
// get_template_part( 'parts/error', 'no_results');
}
get_template_part( 'parts/blog', 'pagination');
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();
}
// display author stuff here
if (is_author()) {
get_template_part( 'parts/bio');
}
?>
</div>
</div>
</div>
</div>
</div>
Could you let me know what's wrong? 你能让我知道怎么了吗? I think it might have something to do with $wp_query. 我认为这可能与$ wp_query有关。 The webpage in question is http://disa.com.sv/constructora/?page_id=10 . 有问题的网页是http://disa.com.sv/constructora/?page_id=10 。
Found an answer. 找到了答案。 It's not in the code. 它不在代码中。 The code is fine. 代码很好。 What's important is the functions.php. 重要的是functions.php。
https://wordpress.stackexchange.com/questions/181487/archive-page-limiting-posts-per-page https://wordpress.stackexchange.com/questions/181487/archive-page-limiting-posts-per-page
I edited it and it work now. 我对其进行了编辑,现在可以使用。
However the problem is that it kept displaying the same 5 posts instead of 14 different posts. 但是,问题在于它一直显示相同的5个帖子,而不是14个不同的帖子。 Help? 救命?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.