有multiple ways of showing 按分类法列出的(自定义)帖子列表,但似乎不允许分页。
因此,我可以很容易地列出所有帖子,如:
Page 1
- 1
- 2
- 3
- 4
- 5
Page 2
<只需稍加努力,我就可以列出按分类法分组的帖子Page 1
- A
- 1
- 2
- B
- 3
- 4
- 5
- 6
- C
- 7
- 8
- D
- 9需要帮助的是混合分页,例如。
Page 1
- A
- 1
- 2
- B
- 3
- 4
- 5
Page 2
<有什么想法吗?示例代码如下:
?><?php // Get current Category $get_current_cat = get_term_by(\'name\', single_cat_title(\'\',false), \'category\'); $current_cat = $get_current_cat->term_id; // List posts by the terms for a custom taxonomy of any post type $post_type = \'myposttype\'; $tax = \'mytaxonomy\'; $tax_terms = get_terms( $tax, \'orderby=name&order=ASC\'); if ($tax_terms) { foreach ($tax_terms as $tax_term) { $args = array( \'post_type\' => $post_type, "$tax" => $tax_term->slug, \'post_status\' => \'publish\', \'posts_per_page\' => -1, \'category__in\' => $current_cat // Only posts in current category (category.php) ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) : ?> <h2><?php echo $tax_term->name; // Group name (taxonomy) ?></h2> <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <?php $term_list = wp_get_post_terms($post->ID, \'category\', array("fields" => "ids")); // Get post categories IDs?> <?php if (in_array($current_cat, $term_list) ): // Display only posts that have current category ID ?> <h3><?php the_title(); ?></h3> <?php endif; // if in_array ?> <?php endwhile; // end of loop ?> <?php endif; // if have_posts() wp_reset_query(); } // end foreach #tax_terms } // end if tax_terms
- 9需要帮助的是混合分页,例如。
- D