• Resolved New_WP

    (@baxter89)


    Hello,
    I can’t display the categories I created on my single publication page, I tested the PHP code provided in the site documentation and it doesn’t work. Can you help me to display on my publication page only the field which corresponds to my category, I do not need to have a link which refers to the category.

    I use ACF and created: A group of fields – a Custom Post Type and a taxonomy

    WP Code and Short code

    THANKS

    • This topic was modified 4 months, 3 weeks ago by New_WP.
Viewing 1 replies (of 1 total)
  • Thread Starter New_WP

    (@baxter89)

    <?php
    if (have_posts()) :
    while (have_posts()) : the_post();
    $terms = get_field('your_taxonomy_field_name');
    if ($terms && !is_wp_error($terms)) :
    $prefix = 'Catégorie : ';
    echo '<ul class="custom-taxonomies">';
    foreach ($terms as $term_id) :
    $term = get_term($term_id);
    if ($term && !is_wp_error($term)) :
    echo '<li>' . esc_html($prefix . $term->name) . '</li>';
    endif;
    endforeach;
    echo '</ul>';
    endif;
    endwhile;
    endif;

    CSS :
    .custom-taxonomies {
    list-style-type: none; /* Enlève les puces */
    padding: 0; /* Enlève le padding par défaut */
    }

    .custom-taxonomies li {
    display: inline-block; /* Affiche les éléments en ligne */
    margin-right: 10px; /* Espace entre les éléments */
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.