gpt4 book ai didi

php - Wordpress 网格未显示所有帖子

转载 作者:行者123 更新时间:2023-11-28 06:35:56 24 4
gpt4 key购买 nike

我一直在构建一个砖石风格的 wordpress 主题,但遇到了障碍,我的网格无法显示所有已发布的帖子。

我目前将每页帖子设置为 100 个帖子,并且我有 18 个已发布的帖子,但每页只显示 8 个,其余 4 个帖子显示在下一页。我希望所有帖子都显示在同一页面上。

我的主要目标是实现 3 列网格,我已经实现了。但是我的内容没有完全显示。

网址:http://www.dwaynecrawford.com/themes/

我的PHP:

    <?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Test Theme
* @since 2015 1.0
*/

get_header(); ?>

<section class="work" id="work">
<!-- Begin WP Grid -->

<div class="masonry">
<?php
$counter = 1; //start counter

$grids = 3; //Grids per row

global $query_string; //Need this to make pagination work


/*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');


if(have_posts()) : while(have_posts()) : the_post();
?>
<?php
//Show the left hand side column
if($counter == 2) :
?>
<div class="item">

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail('category-thumbnail'); ?>
</a>

<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php
//Show the right hand side column
elseif($counter == $grids) :
?>
<div class="item">

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail('category-thumbnail'); ?>
</a>

<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php $counter = 0;
endif;
?>
<?php
$counter++;
endwhile;
//Pagination can go here if you want it.
endif;
?>

</div>

<article class="underpost">
<?php posts_nav_link(); ?>
</article>
</section>

CSS:

.masonry {
margin: 0em 0;
padding: 0;
-moz-column-gap: 0em;
-webkit-column-gap: 0em;
column-gap: 0em;
font-size: 0em;
}
.item {
display: inline-block;
background: #fff;
padding: 0px;
padding: 0;
margin: 0 0 0 0;
width: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.item:hover {
background-color: black;
opacity: 0.2;
}
.item img {
width: 100%;
height: auto;
}
.item img.attachment-post-thumbnail {
width: 100%;
}
@media only screen and (min-width: 400px) {
.masonry {
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
}
}
@media only screen and (min-width: 700px) {
.masonry {
-moz-column-count: 2;
-webkit-column-count: 2;
column-count: 2;
}
}
@media only screen and (min-width: 900px) {
.masonry {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
}
@media only screen and (min-width: 1100px) {
.masonry {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
}
@media only screen and (min-width: 1280px) {
.wrapper {
width: 1260px;
}
}

最佳答案

在回顾我的问题后,我找到了解决方案。

query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');

我已将值从 posts_per_page=12 更改为 100 个帖子。

关于php - Wordpress 网格未显示所有帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34685185/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com