我已经为我的自定义帖子创建了一个归档页面,它会循环浏览除第一篇以外的所有帖子。总共有11篇帖子,我在归档页面上只得到10篇。
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\' );