[Resolved] Strange issue with dashicons

Home Forums Support Strange issue with dashicons

This topic contains 6 replies, has 2 voices, and was last updated by  Leo 2 months, 2 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #1194967


    I have a strange issue. I am including dashicons on the front-end through

    add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
    function load_dashicons_front_end() {
    	wp_enqueue_style( 'dashicons' );

    Then I enter dashicon HTML in the Navigation Label of my menu items, for example:
    <span class="dashicons dashicons-admin-home"></span> Home

    I also have a wp-head hook only on the blog archive that truncates the post titles to the first 7 words:

    add_filter( 'the_title', 'wpse_75691_trim_words' );
    function wpse_75691_trim_words( $title )
    	// limit to 7 words
    	return wp_trim_words( $title, 7, '...' );

    It works for the whole site except the blog archive where the dashicons disappear from the menu items. Removing the truncate script gets the icons back again on the blog archive. Settings the hook to wp_footer is a no-go since it doesn’t work.

    I have tried different priorities for both scripts but nothing. Also nothing in the logs. I have also tried putting the truncate script in functions.php instead of a hook, same problem.


    Leo Customer Support

    Hi there,

    That’s strange.

    Does the problem only occur on the main posts page? What about archives etc?

    Any chance you can try a twenty series default theme and see if the same issue occurs?

    Let me know 🙂



    Hi Leo.

    Yeah, it happens with a twenty them as well. It occurs wherever that truncate code exists. If I activate it for the entire site, it will strip icons from the entire site. It seems it’s not theme-specific. I believe, I have this problem here:


    but for dashicons.

    Still, no idea how it can be solved, though…If you can suggest something, I will take it!


    Leo Customer Support

    Sorry I don’t have a suggestion for this.

    Maybe ask on a forum like this?



    I will, thanks Leo.



    I received the solution on this thread.

    function wpse_360758_trim_words( $title, $post_id ) {
        if ( is_admin() ) {
            return $title;
        if ( in_the_loop() && 'post' === get_post_type( $post_id ) ) {
            $title = wp_trim_words( $title, 7, '...' );
        return $title;
    add_filter( 'the_title', 'wpse_360758_trim_words', 10, 2 );

    Thanks again!


    Leo Customer Support

    Glad you found a solution!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.