Breadcrumbs filter still doesn't allow html data

#6307
  • Resolved BLMMedia
    Rank Math free

    In regards to this thread: https://support.rankmath.com/ticket/breadcrumb-functionality-seems-limited/

    I have this:

    
    add_filter( 'rank_math/frontend/breadcrumb/settings', 'blm_modify_breadcrumb_settings', 10, 1);
    add_filter( 'rank_math/frontend/breadcrumb/strings', 'blm_modify_breadcrumb_strings', 10, 1);
    

    This one works now after the recent bugfix:

    
    function blm_modify_breadcrumb_settings( $settings ) {
    	$settings = array(
    		'home'           => true,
    		'separator'      => '<i class="icon-fa-angle-right"></i>',
    		'remove_title'   => '',
    		'hide_tax_name'  => '',
    		'show_ancestors' => '',
    	);
    	return $settings;
    }
    

    However this one works if you add plain text, but it doesn’t allow html and defaults back to the setting in admin:

    
    function blm_modify_breadcrumb_strings( $strings ) {
    	$strings = array(
    		'prefix'         => '',
    		'home'           => '<i class="icon-fa-home"></i><span class="desktop">Home</span>',
    		'error404'       => '',
    		'archive_format' => '',
    		'search_format'  => '',
    	);
    	return $strings;
    }
    

    Please advise.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    This filter is only designed to return strings, have you been able to try the following filter to modify the actual HTML:

    /**
     * Filter to change breadcrumb html.
     *
     * @param  html  $html Breadcrumb html.
     * @param  array $crumbs Breadcrumb items
     * @param  class $class Breadcrumb class
     * @return html  $html.
     */
    add_filter( 'rank_math/frontend/breadcrumb/html', function( $html, $crumbs, $class ) {
    	// theme_breadcrumb_function();
    	return $html;
    }, 10, 3);

    I am looking forward to helping you. Thank you.

    ​​​​​​​

    Hi Michael,

    Are you saying I would need to so a string replacement on $html, in the most simple example, such as:

    
    $html = str_replace('">Home</a>', '"><i class="icon-fa-home"></i><span class="desktop">Home</span></a>', $html);
    

    That doesn’t seem like the most reliable method. :/

    HI there,

    Thanks for the follow up.

    I have been able to reproduce this issue and I have submitted this to our developers for closer investigation.

    We will be getting back to you in a short while.

    Thank you.

    Thanks Michael!

    Todd
    Rank Math free

    You are very welcome.

    We will get back to you when we have an update on this.

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

The ticket ‘Breadcrumbs filter still doesn't allow html data’ is closed to new replies.