select category for breadcrumb

#178239
  • Hi there!

    Is it possible with your plugin to manualy select which woocommerce category has to show up in the breadcrumbs?

    This would be a perfect funtion to optimize my internal linking.

    Hope to hear from you soon.

    Kinds regards,
    Sander

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

    Thanks for contacting us.

    You can use the code given below to use a custom category to be displayed in your breadcrumbs:

    /**
     * Allow changing or removing the Breadcrumb items
     *
     * @param array       $crumbs The crumbs array.
     * @param Breadcrumbs $this   Current breadcrumb object.
     */
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
        //Adding to single posts
    	global $post;
    	if(is_singular('product')){
    		$newValue[] = array(
    			'Name of your Category',
    			'URL of your category',
    			'hide_in_schema' => false
    		);
    		array_splice( $crumbs, 1, 1, $newValue );
    		return $crumbs; 
    	}
    	return $crumbs;
    }, 10, 2);

    Paste this code in your theme’s functions.php file.

    Hope this helps. Let us know if you need any further assistance.

    Hi Jaideep,

    Thank you for your quick reply!

    This is not exactly what I mean. The function i’m looking for is selecting per product what productcategory to show in the breadcrumb.

    Sorry to mention this; with yoast you can select which category path you want to show in the breadcrumbs. Is this also possible with Rankmath?

    Kind regards,
    Sander

    Hello,

    Thank you for the follow-up.

    Could you please confirm if this screencast I’ve created is the one you wanted to achieve?
    https://i.rankmath.com/Eiwa7F

    I’ve selected a category and subcategory in the product and selected the subcategory as a primary term to display the path Home > category > subcategory > product in Rank Math Breadcrumbs.

    Please also note that some options are only available when you enable the Advanced Mode in Rank Math. If it’s not showing, you must have chosen to use the Easy Mode. Please follow the steps in this link to switch to Advanced Mode:
    https://rankmath.com/kb/advanced-mode/

    If that didn’t help, could you please provide a screenshot or affected links to check further?

    I hope that helps. Thank you, and looking forward to your update.

    Hi Reinelle,

    That did the trick, i’m now able to select the preferred category to show up in the breadcrumb.

    Thanks a lot!!

    Kind regards,
    Sander

    Hello,

    We are super happy that this issue is already resolved. 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 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 5 replies - 1 through 5 (of 5 total)

The ticket ‘select category for breadcrumb’ is closed to new replies.