0

This code work perfect, but I want to show child image too. I use ACF plugin.

Can you help me please?

$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>';
    }
}
0
0

I found a solution.

 <?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>';


                            }
                            }
                ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.