Why is my archive page looping through all but one post?

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' );

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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' );


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x