Show portfolio category in Breadcrumbs

#401008
  • Resolved IMK
    Rank Math free

    Hello,

    I would like to know how I can show the portfolio category in the breadcrumbs.

    I have tried to enable “show category” from Rank >> Math >> Settings >> Show category(s)

    But unfortunately it does not appear.

    I would appreciate your help.

    Best regards

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

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Could you please share the affected URL so we can check as well?

    Meanwhile, that option is if your current post is part of a child category, then the breadcrumb will include the parent categories as well.

    Looking forward to helping you.

    Thank you.

    IMK
    Rank Math free

    Hello Reinelle,

    Thank you for your prompt reply.

    I share with you an example url: https://cutt.ly/kJAVsQ7

    However, I have to rephrase my question. Sorry for the inconvenience

    That page is a CPT (Portfolio) and I would like to add in the breadcrumbs a top level, in this case, the services page.

    Note: I should clarify that “Services” is a page and not a category of the portfolio.

    Here is an example:

    Home>>>Services>>>Buying and selling Paintings

    Regards

    Prabhat
    Rank Math agency

    Hello,

    Please add the below filter to the website and see if it gives you the desired output:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	if(get_post_type() === 'test_cpt' && false === is_tax()){  // Replace test_cpt with the CPT slug
    		array_splice( $crumbs, 1, 0, array(array(
    			"Services", // Replace with page name
    			"https://yourwebsite.com/services/", // Replace with page URL
    			"hide_in_schema" => false
    		)) );
    	}
    	return $crumbs;
    }, 10, 2);

    Before adding, please replace:
    1. test_cpt with the CPT slug.
    2. Services with the page name or the text to be displayed in the breadcrumbs.
    3. https://yourwebsite.com/services/ with the URL of the desired page.

    Here’s a guide you can follow to add the filter:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Let us know how that goes.

    Thank you.

    IMK
    Rank Math free

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    IMK
    Rank Math free

    Hi Rabhat,

    I have added your code, but it still doesn’t work. I’m probably doing something wrong

    I have provided you with a url with temporary access.

    Sorry for the inconvenience

    Thank you very much for your help

    Hello,

    I have modified the filter and now it is working as expected. Please check and let us know if you need any other assistance.

    Thanks.

    IMK
    Rank Math free

    Hi Jaideep Asrani,

    You are amazing, thank you for your help.

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘Show portfolio category in Breadcrumbs’ is closed to new replies.