简体   繁体   中英

Wordpress grid not showing all posts

I have been building a masonry styled wordpress theme, and I've run into a road block where my grid will not show all of the published posts.

I currently have my posts per page set to 100 posts, and I have 18 published posts, but only 8 show per page, with the remaining 4 posts showing on the next page. I want all of the posts to show on the same page.

My main goal is to achieve a 3 column grid, which I have achieved. But my content isn't showing completely.

Web URL : http://www.dwaynecrawford.com/themes/

My 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;
    }
}

After time going back through my problem, I have found the solution.

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

I have changed the value from posts_per_page=12 to 100 posts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM