“Obtenir des taxonomies” Réponses codées

Afficher toutes les conditions d'une taxonomie personnalisée

$terms = get_terms( array(
  'taxonomy' => 'taxonomy_name_or_slug',
  'hide_empty' => true,
) );
foreach ($terms as $term){
  echo $term->slug;
  echo $term->name;
  echo "<br><br>";
}
gtamborero

Obtenir des taxonomies

$index_query = new WP_Query(array('post_type' => 'company', 'posts_per_page' => '-1', 'order' => 'DESC'));

while ($index_query->have_posts()) : $index_query->the_post();

    $taxonomy_ar = get_the_terms($post->ID, 'tax-name');

    $output = '<span class="btn">';
    foreach($taxonomy_ar as $taxonomy_term) {
        $output .= '<a href="'.get_term_link($taxonomy_term->slug, 'title').'">'.$taxonomy_term->name.' <span class="label">'.$taxonomy_term->count.'</span></a> ';
    }
    $output .= '</span>';

    echo $output;

endwhile;​
Difficult Dunlin

Réponses similaires à “Obtenir des taxonomies”

Questions similaires à “Obtenir des taxonomies”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code