HTML in Home breadcrumb element

#951613
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    We apologize for the issue you are facing regarding the breadcrumb navigation. Thank you for raising this concern.

    To replace the word "Home" with an HTML icon in the breadcrumbs, you would need to modify the way breadcrumbs are generated in Rank Math. Since the wp_strip_all_tags function is used in the add_crumb function, it strips out any HTML tags, which prevents you from inserting an icon directly.

    Currently, there isn’t a built-in option in Rank Math to achieve this directly through settings. However, you can customize the breadcrumb output by using filters provided by Rank Math. You might consider using the rank_math/frontend/breadcrumb/html filter to modify the breadcrumb HTML after it has been generated.

    Here’s a basic example of how you could implement this:

    add_filter( 'rank_math/frontend/breadcrumb/html', function( $html ) {
        // Replace "Home" with an HTML icon
        $html = str_replace('Home', '', $html);
        return $html;
    });

    This code snippet would replace the word "Home" with a Font Awesome home icon. You can add this code to your theme’s functions.php file or a custom plugin.

    If you have further questions or need more assistance, please reply to this ticket, and a human agent from the Rank Math Support team will take over and provide additional help.

    Sources:
    How to Make Your Theme Rank Math Compatible » Rank Math

    This isn’t really a sustainable solution. If the rest of my breadcrumbs just have the word “Home” in them, it’ll cause problems. I could replace the entire A tag on the home page, but if part of the tag changes for some reason, it’ll stop working. An additional argument to bypass wp_strip_all_tags for the home page in the rank_math_the_breadcrumbs function would be ideal.

    For the moment i’ve replaced “Home” with a more unique string “REPLACEHOMESTRING” and applied the suggested filter.

    “REPLACEHOMESTRING” is a bad idea, the word also appears in the json ld. I ended up replacing the entire A tag.

    $home_link = '<a href="' . get_home_url() . '">' . __('Accueil', 'wpb') . '</a>';
    $html = str_replace($home_link, '<a href="' . get_home_url() . '"><i class="fa-solid fa-house"></i></a>', $html);

    Hello,

    Can you please confirm if you want to change the Homepage level on breadcrumbs with an icon? If so, you can directly use the icon in Rank Math > General Settings > Breadcrumbs:

    Let us know how it goes. Looking forward to helping you.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘HTML in Home breadcrumb element’ is closed to new replies.