În folderul temei WordPress se creează un fişier cu alias-ul respectivei categorii (de ex. dacă e vorba de categoria Utilităţi, va fi creat fişierul category-utilitati.php).
Conţinutul necesar enumerării subcategoriilor (util mai ales pentru un widget) – ambalat, desigur, în codul specific afişării în cadrul temei respective ar fi:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<?php $id_cat_actuala = get_queried_object_id(); $children = get_terms([ 'taxonomy' => get_queried_object()->taxonomy, 'parent' => $id_cat_actuala, ]); $terms = get_terms([ 'taxonomy' => get_queried_object()->taxonomy, 'parent' => get_queried_object_id(), ]); ?> <ul style="list-style-type:none;padding:0;"><?php FOREACH ( $terms as $term) {?> <li> <a style="text-decoration:none;" href="<?php ECHO get_term_link( $term ); ?>"> <?php ECHO $term->name; ?> </a> </li><?php } ?> </ul> |
Un pic mai simplu este în exemplul următor:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$args = array( 'child_of' => 561 ); $terms = get_categories($args); ?> <ul style="list-style-type:none;padding:0;"><?php FOREACH ($terms AS $term) { ?> <li> <a style="text-decoration:none;" href="<?php ECHO get_term_link( $term ); ?>"> <?php ECHO $term->name; ?> </a> </li><?php } ?> </ul> |
În ambele cazuri, rezutatul ar putea arăta astfel: