NOTE: If you're new to this question, it is already solved you just need to add the 'posts+per_page' parameter in the new WP_Query array... I wonder why they(stackoverflow developers) do not give us an option to answer our own questions and accept them as correct ones.

So this is the first time in which something like this happens to me. I’ve used the same method in some of my last projects and it works well but in the current template in which I’m working it is not.

Here is the custom page that displays the custom post type(snippets):

    Template Name: Snippets
    Template Post Type: page
    <?php get_header(); ?>
    <?php include("includes/page-header.php"); ?>
    <div class="container">
        <!-- Page Heading -->
        <div class="row">
            <div class="col-md-12">
                <div class="pull-left">
                    <button class="btn btn-sm btn-default" data-toggle="portfilter" data-target="all">All</button>
                            $terms = get_terms("snippets_categories"); // Consigue todas las categorias del custom taxonomy.
                            $termsString .=  $term->slug;
                            $count = count($terms); //Cuantos categorias son?
                            if ( $count > 0 ){  //Si es que hay mas de uno
                                foreach ( $terms as $term ) {  //Para cada termino:
                                    echo "<button class='btn btn-sm btn-primary' data-toggle='portfilter' data-target='".$term->slug."'>".$term->name."</button>\n";
            <div class="clearfix"></div>
                $snippets_query = new WP_Query(array(
                    'post_type' => 'snippets',
                    'order' => 'DESC',
'posts_per_page' => -1,
            <?php if($snippets_query->have_posts()) : while($snippets_query->have_posts()) : $snippets_query->the_post();?>
                <?php $terms_snippets = get_the_terms( get_the_ID(' '), 'snippets_categories'); ?>
                    $terms_snippet_slugs = array();
                    foreach ($terms_snippets as $tp) {
                        $terms_snippet_slugs[] = $tp->slug;
                    $terms_snippet_csv = implode (' ',$terms_snippet_slugs);
                <a class="snippet" href="<?php the_permalink(); ?>" data-tag="<?php echo $terms_snippet_csv; ?>"><?php the_title(); ?></a>
            <?php endwhile; ?>
            <?php  else : ?>
                <div class="alert alert-danger text-center"><p>Ningun snippet encontrado</p></div>
            <?php endif; ?>
    </div><!-- /Container --->
    <!-- /.row -->
    <?php get_footer(); ?>

This is my problem, I currently have 12 published posts. 2 with the category of Javascript, 2 others with the category of CodeIgniter, and 8 posts with the category of WordPress. I don’t know what the problem is but all the posts with the category of WordPress are not displayed in the custom page.

Any idea on how to fix this? Thanks is advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.