Adding breadcrumbs on specific pages

#402625
  • Resolved IMK
    Rank Math free

    Adding breadcrumbs on specific pages

    Hello,

    I am following the steps in the following thread: https://support.rankmath.com/ticket/show-portfolio-category-in-breadcrumbs/ to implement breadcrumbs on specific pages and also to be able to show in the breadcrumbs the top page or a specific page I am interested in.

    I share a couple of examples:

    Example 1: Home >> Buy Art >> 20th CENTURY | See url: https://bit.ly/3QaZfm4

    Example 2: Home >> Artists >> 20th CENTURY | See url: https://bit.ly/3muR9qH

    If I add “page” as get_post_type(), the top level page is the same in both urls.

    So, I have two questions:
    1. How can I display the name of the breadcrumbs in each url ?

    2. How can I display the breadcrumbs according to their ID?

    Thanks for your help

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

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

    I tried checking the URL you wish to share but I was blocked. Can you please share those links directly in the Sensitive Data section instead?

    With that said, I have modified the code for “Breadcrumbs COMPRAR ARTE” in the snippet plugin.

    I went ahead and targeted the child page using the ID (as part of an answer to your question). Please refer to this code:

    // Retrieving the Page ID:
    global $post;
    
    // Example Usage
    if($post->ID === 4740){
        ...
    }

    Modified filter code:

    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) {
    	global $post;
    	if(get_post_type() === 'page' && false === is_tax() && $post->ID === 4740){  // Replace test_cpt with the CPT slug
    		array_splice( $crumbs, 1, 0, array(array(
    			"COMPRAR ARTE", // Replace with page name
    			"https://rafaellozano.imkclientes.es/comprar-arte/", // Replace with page URL
    			"hide_in_schema" => false
    		)) );
    	}
    
    	return $crumbs;
    }, 10, 2);

    You can do the same for your Artists page.

    If you like us to edit it for you. Kindly let us know and we will be more than happy to do that.

    Looking forward to helping you on this one.

    IMK
    Rank Math free

    Hello Jeremy,

    works.

    Thank you very much for your excellent help.

    You guys are amazing

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Adding breadcrumbs on specific pages’ is closed to new replies.