我试图用自定义分类法和几个子自定义分类法列出单个类别中的帖子。
子自定义分类法“知识库”
发布知识库1发布知识库2子自定义分类法“优化”
术后1but result is repeat post list not by custom taxonomy:
子自定义分类法“知识库”
发布知识库1发布知识库2发布操作1/ul>子自定义分类“优化”
发布知识库1,发布知识库2,发布操作1,例如代码:
$taxonomies = get_terms(
array(
\'taxonomy\' => \'tutorial\',
\'hide_empty\' => false,
)
);
// Loop through categories
foreach ( $taxonomies as $taxonomy ) {
// Display Taxonomy name
echo \'<h2 class="post-title">\' . $taxonomy->name . \'</h2>\';
echo \'<div class="post-list">\';
// WP_Query arguments
$args = array(
\'cat\' => 2, // wordpress category
\'terms\' => name,
\'orderby\' => \'term_order\',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<p><a href="<?php the_permalink();?>"><?php the_title(); ?></a></p>
<?php
} // End while
} // End if