0

I've created an archive page for my custom posts, it loops through every one except the first. There is 11 posts overall and I only get 10 on the archive page.

Here is my archive template:

<div class="container">
  <h2 class="entry-title text-center pt-5">Market Place</h2>
  <p class="text-center">Filter providers by service and click on the logos shown below for more information and to contact a representative of the risk solution provider.</p>
  <div class="category-search-box text-center"><?php echo do_shortcode( '[searchandfilter fields="provider,categories"]' ); ?></div>
  <div class="row py-5">
    <?php if (have_posts()) : while (have_posts()) :the_post();
          $taxonomy = wp_get_object_terms($post->ID, 'categories');
          $ids = "";

          foreach ($taxonomy as $cat) {
           $ids .= "cat-".$cat->term_id ." ";
         }
        ?>
      <div class="col-6 col-md-4 text-center">
        <div id="provider-archive-boxes" class="provider-archive-box <?php echo $ids; ?>">
          <a href="<?php echo the_permalink();?>"><?php the_post_thumbnail( 'full', array( 'class' => 'img-responsive' ) ); ?></a>
          <p><strong><?php the_title();?></strong></p>
        </div>
      </div>
    <?php endwhile; ?>
    </div>
  <?php endif; ?>
</div>

Here is how I registered the post in the functions.php file:

function provider_setup_post_type() {
    $args = array(
        'public'    => true,
        'label'     => __( 'Providers', 'textdomain' ),
                "public" => true,
                "publicly_queryable" => true,
                "show_ui" => true,
                "show_in_rest" => false,
                "rest_base" => "",
                "has_archive" => 'marketplace',
                "show_in_menu" => true,
                "exclude_from_search" => false,
                "capability_type" => "page",
                "map_meta_cap" => true,
                "hierarchical" => true,
                'rewrite' => array('slug' => 'marketplace'),
        'menu_icon' => 'dashicons-building',
                "supports" => array( "thumbnail","post-thumbnail","title", "editor" ),
    );
    register_post_type( 'provider', $args );

        register_taxonomy("categories", array("provider"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => array( 'slug' => 'marketplace', 'with_front'=> false )));
}
add_action( 'init', 'provider_setup_post_type' );
2
0

As @Jacob Peattie says, pagination is what's causing this, and probably what you want to add if you will have more posts over time.

If you want you can disable pagination for archive pages easily with this in your functions.php:

    function wpse_disable_pagination( $query ) {
        if (is_archive()) {
            $query->set('nopaging', 1 );
        }
    }

    add_action( 'pre_get_posts', 'wpse_disable_pagination' );

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.