Issue with Customizing Breadcrumbs Display using Rank Math SEO

#617847
  • Resolved Anonymous
    Rank Math free

    Hello Rank Math Support Team,

    I’m writing to seek assistance with a customization issue I’m facing while trying to modify the breadcrumb display using Rank Math SEO on my WordPress website (Schema theme).

    I followed the instructions provided by your support team here and attempted to use the code snippet that was shared However, despite my efforts, the desired customization has not been successfully implemented.

    I’m trying to display the SEO title instead of the article title in the breadcrumbs. I incorporated the provided code snippet into my theme’s functions.php file as instructed, but the expected results were not achieved.

    Could you please review the code snippet and my implementation to identify any potential issues? Additionally, if there are any alternative approaches to achieve this customization, I would greatly appreciate your guidance.

    Here is the code snippet I added to my functions.php file:

    $seo_title = get_post_meta( $post->ID, 'rank_math_title', true );
    if ( ! empty( $seo_title ) ) {
    $title = RankMath\Helper::replace_vars($seo_title);
    } else {
    $title = $post->post_title;
    }

    I have ensured that the necessary variables are defined correctly and that the Rank Math plugin is up to date. However, despite these efforts, the breadcrumb customization is not working as expected.

    Your expertise and guidance in resolving this matter would be greatly appreciated. If there are any additional steps I should take or any other code adjustments that need to be made, please let me know.

    Thank you very much for your time and assistance. I look forward to your prompt response.

    Best regards,
    StepHania.

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

    Thanks for contacting us and sorry for the inconvenience caused.

    Please use the following filter to replace the post tile with the SEO title in the breadcrumbs:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	global $post;
    	$seo_title = get_post_meta( $post->ID, 'rank_math_title', true );
    	if(! empty( $seo_title )) {
    		$crumbs[count($crumbs)-1][0] = get_post_meta( $post->ID, 'rank_math_title', true );		
    	} elseif(empty($seo_title)) {
    		$title = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_title" );
    		$title = RankMath\Helper::replace_vars( $title, $post );
    		$crumbs[count($crumbs)-1][0] = $title;	
    	}
    	return $crumbs;
    }, 10, 2);

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Let us know if you need any other assistance.

    Anonymous
    Rank Math free

    Perfect! Thanks a lot!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

The ticket ‘Issue with Customizing Breadcrumbs Display using Rank Math SEO’ is closed to new replies.