我的网站上有此页面-
这是一个自定义分类法模板,用于一个名为Directory Entries的自定义post类型,其分类法名为Directory\\u entry\\u type,这就是这里要引入的内容。
目前,它只是在“社区目录”类别下拉入所有帖子-这个类别有大约6个子类别,我想在这个页面上拉入,但目前它只是在社区目录下拉入所有帖子。
我该怎么做?
这就是我目前要做的-
<div id="content" class="col-md-8">
<?php
$queried_object = get_queried_object();
$term_query = $queried_object->term_id;
$current_term = get_term_by( \'slug\', get_query_var( \'term\' ), get_query_var( \'taxonomy\' ) );
query_posts( array(
\'posts_per_page\' => -1, // you may edit this number
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'child_of\' => $current_term->term_id,
\'hierarchical\' => true,
\'depth\' => 1,
\'tax_query\' => array(
array(
\'field\' => \'term_id\',
\'terms\' => $term_query,
\'taxonomy\' => $current_term->taxonomy,
)
),
\'meta_query\' => array(
array(
\'key\' => \'is_member\',
\'value\' => \'1\',
\'compare\' => \'LIKE\'
)
)
)
);
?>
<div class="grid-vw">
<ul>
<?php while (have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink();?>">
<figure class="effect-goliath">
<?php
$image = get_field(\'thumbnail\');
$size = \'dir-tile\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
<figcaption>
<h2><?php the_title();?> ></h2>
</figcaption>
</figure>
</a>
</li>
<?php endwhile;
wp_reset_query();
?> </ul>
</div>
提前感谢您的帮助!
编辑
所以我用这个解决了这个问题
<div class="grid-vw">
<ul>
<?php
// List posts by the terms for a custom taxonomy of any post type
$post_type = \'directory_entry\';
$tax = \'directory_entry_type\';
$tax_args = array(
\'order\' => \'ASC\',
\'parent\' => 289
);
// get all the first level terms only
$tax_terms = get_terms( $tax, $tax_args );
if ($tax_terms) {
foreach ($tax_terms as $tax_term) { // foreach first level term
// print the parent heading
?>
<li>
<a href="<?php echo get_permalink( $tax_term->ID ); ?>">
<figure class="effect-goliath">
<?php
$image = get_field(\'thumbnail\');
$size = \'dir-tile\'; // (thumbnail, medium, large, full or custom size)
if( $image ) {
echo wp_get_attachment_image( $image, $size );
}
?>
<figcaption>
<h2><?php echo $tax_term->name; ?> ></h2>
</figcaption>
</figure>
</a>
</li>
<?php wp_reset_query();
}
}
?>
</ul>
这正是我想要的,但现在permalinks不起作用了,有人能告诉我我做错了什么吗?