这个代码工作得很好,但我想展示一下child image 也我使用ACF插件。
你能帮帮我吗?
$term = get_queried_object();
$children = get_terms( $term->taxonomy, array(
\'parent\' => $term->term_id,
\'hide_empty\' => false
) );
if ( $children ) {
foreach( $children as $subcat ) {
echo \'<a href="\' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . \'">\'.\'<span> مقالات دسته</span>\' . $subcat->name . \' </a>\'.\'</div>\';
}
}
最合适的回答,由SO网友:Imfairyyyyy 整理而成
我找到了解决办法。
<?php
$term = get_queried_object();
$children = get_terms( $term->taxonomy, array(
\'parent\' => $term->term_id,
\'hide_empty\' => false
) );
if ( $children ) {
foreach( $children as $subcat ) {
$size = "thumbnail";
echo \' <div class=" cat-box ">\';
$image = get_field(\'image\', \'category_\' . $subcat->term_id);
echo \'<img src="\' . $image . \'" />\';
echo \'<a href="\' . esc_url(get_term_link($subcat, $subcat->taxonomy)) . \'">\' . \'<span> مقالات دسته</span>\' . $subcat->name . \' </a>\' . \'</div>\';
\'</div>\';
}
}
?>