Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John James Jacoby

    (@johnjamesjacoby)

    Try: echo get_term_meta( $term_id, 'icon', true );

    Where $term_id is the numeric ID of the term you want to get the icon for.

    I tried the above code: echo get_term_meta( $term_id, ‘icon’, true );
    and the icon is not showing up only it’s name, for example:
    dashicons-admin-comments.

    I got it working with an added code for displaying the icon image, not only the icon name.

    <?php

    // get current taxonomy term id on wordpress

    $term_id = get_queried_object()->term_id;

    // get the icon for the current term_id (found above)

    $iconpic = get_term_meta( $term_id, ‘icon’, true );

    // show the icon on the page

    echo ‘<div class=”dashicons ‘ .$iconpic.'”></div>’;

    ?>

    Please let me know if there is a better way to display the icons on the archive page for the current category / tag.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get icon in the post’ is closed to new replies.