我一直在努力根据分类法slug“peers”引入自定义帖子,我不知道我做错了什么!
\'coaches_post_type\' => [
\'slug\' => \'coaches\',
\'name_plural\' => \'Coaches\',
\'name_singular\' => \'Coach\',
\'taxonomy_slug\' => \'coaches_category\',
\'taxonomy_rewrite\' => \'coaches-category\',
\'taxonomy_name_plural\' => \'Coach Categories\',
\'taxonomy_name_singular\' => \'Coach Category\'
],
public static function WhoHTML() {
$args = array(
\'post_type\' => \'coaches\',
\'posts_per_page\' => \'4\',
\'order\' => \'DESC\',
\'orderby\' => \'date\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'coaches_category\',
\'field\' => \'slug\',
\'terms\' => \'peers\'
)
)
);
$coaches = new WP_Query($args);
foreach ($coaches->posts as $coach) {
$image = get_the_post_thumbnail_url($coach->ID);
$html .= "<div class=\'single-coach\'>
<img class=\'coach-image img-responsive\' src=\'$pluginDirectory/assets/images/square.png\' />
<p class=\'coach-name\'>{$coach->post_title}</p>
</div>";
}
echo $html;
return;
}