Bonjour,
Sur mon site j'ai un système de recherche par catégories et à chaque catégorie est associé une icone.
Petit problème lorsque je souhaite créer une sous catégorie, celle ci affiche l'icone de la catégorie parent au lieu de sa propre icone.
voici le code de la function
Merci par avance de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 /* Get icon of the category */ function classifieds_get_cat_icon( $post_id = '' ) { if ( empty( $post_id ) ) { $post_id = get_the_ID(); } $cats = wp_get_post_terms( $post_id, 'ad-category' ); if ( ! empty( $cats ) ) { foreach ( $cats as $cat ) { if ( $cat->parent == 0 ) { $term_meta = get_option( 'taxonomy_' . $cat->slug ); $icon = isset( $term_meta['category_marker'] ) ? $term_meta['category_marker'] : ''; if ( ! empty( $icon ) ) { if ( ! empty( $icon ) ) { $icon_data = wp_get_attachment_image_src( $icon, 'full' ); $icon = $icon_data[0]; } return $icon; } } } } }
Partager