我有从分类法加载的帖子,但我正在尝试获取另一个帖子的数据,这也附加到同一个帖子上。在下面的代码中,主要关注点是$location_slug
. 如果知道如何获取这些数据,我想我会知道如何从第二种分类法中获取更多数据。
// args for the term_query
$sub_taxonomy = \'department_categories\';
$tax_args = array(
\'taxonomy\' => $sub_taxonomy,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'hide_empty\' => false,
);
$the_query = new WP_Term_Query($tax_args );
// loop through the terms returned
foreach($the_query->get_terms() as $term){
$term_id = $term->term_id;
$term_name = $term->name;
$term_slug = $term->slug;
// args for the post query
$post_type = \'career\';
$tax_query = array(
array(
\'taxonomy\' => $sub_taxonomy,
\'field\' => \'id\',
\'terms\' => $term_id,
// \'operator\' => \'IN\',
)
);
$post_args = array(
\'posts_per_page\' => -1,
\'orderby\' => \'name\',
\'order\' => \'asc\',
\'post_type\' => $post_type,
\'tax_query\' => $tax_query
);
$primary_taxonomy = \'location_categories\';
$location = get_term( $term_id, $primary_taxonomy);
$location_slug = $location->slug;
query_posts( $post_args );
$html_out .= \'<h6>\' . $term_name . \'</h6>\';
$html_out .= \'<div data-id="\' . $location_slug . \'" class="tab-pane fade in">\';
$html_out .= \'<div>\';
$html_out .= \'<div class="uncode_text_column">\';
// lopp through the posts
if (have_posts()) : while (have_posts()) : the_post();
$product_title = get_the_title();
$product_link = get_the_permalink();
$html_out .= $product_title;
endwhile; else: endif;
$html_out .= \'</div>\';
$html_out .= \'</div>\';
$html_out .= \'</div>\';
}