Different breadcrumbs

#722369
  • Resolved LIP Trade
    Rank Math free

    Hello, we are using your app on several sites and we are happy with it, thank you for that. The following incident occurred for our client. He’s using breadcrumbs, but he wants it to load not the category path in his post, but the page path. The idea is that the post archive has one design, and the corresponding page that loads the given category is intentionally a different design. The client wants the page with the specific design to load, not just an archive of posts, as is the default. We dug into the knowledge base, but we didn’t find exactly such a solution. I hope we have explained clearly. We also indicate the site in question, for more clarity.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello, we apologize for the inconvenience your client is facing. We appreciate your feedback and are glad to hear that you are happy with our app.

    To load the page path instead of the category path in the breadcrumbs, you can use custom code snippets to modify the breadcrumbs on your site. However, this customization goes beyond the options available in the settings.

    You can refer to this guide on adding filters to your WordPress site for more information on how to achieve this customization.

    If you have set a static page as your blog page, you can navigate to WordPress DashboardRank Math SEOGeneral SettingsBreadcrumbs and enable the Show Blog Page option. Then, click Save Changes.

    Enable Show Blog Page

    This option will be unavailable if you have not set a static page as your blog page in WordPress. In that case, you can use a filter to add a Blog page to your breadcrumbs. Please ensure to replace https://yourdomain.com/blog with your blog URL.

    We hope this helps! If you need further assistance, please feel free to reach out.

    Sources:
    Rank Math General Settings
    How to Enable Breadcrumbs on Your Website With Rank Math SEO » Rank Math
    How to Customize Breadcrumbs in Rank Math » Rank Math

    LIP Trade
    Rank Math free

    Thanks for the quick reply. We don’t need the Blog option as we don’t exactly have such a specific section. I hope this is not a problem. We need only the pages on the breadcrumb trail to be shown to us, including in posts. Which exact filter of yours can you direct us to?

    Hello,

    Thank you for contacting support.

    It’s possible to modify the current output of the breadcrumbs by modifying the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#change-remove-breadcrumb-items

    The modification is very specific for each website but here’s an example of trying to eliminate the categories from the breadcrumbs:

    
    /** 
    * Filter to remove categories from Rank Math Breadcrumbs. 
    */ 
    add_filter( 'rank_math/frontend/breadcrumb/items', function( $crumbs, $class ) { 
            // check if we are viewing single posts
    
            if(is_singular('post')){ //Unset elements with key 1        
              unset($crumbs[2]); // Change the index to remove the category
              $crumbs = array_values($crumbs);      
              return $crumbs;   
            }   
            return $crumbs; 
    }, 10, 2);
    

    Please note that this is removing the category entirely and your case it seems that you want to change that for a particular page so you need to consult with a developer on how this can be achieved.

    Don’t hesitate to get in touch if you have any other questions.

    LIP Trade
    Rank Math free

    Thanks for the specific answer. If I understand you correctly, this code can be adapted for each specific blog page? I give an example of something that “Breadcrumb NavXT” came up with, namely:
    ———————————————————————–
    add_filter(‘bcn_breadcrumb_url’, ‘my_breadcrumb_url_changer’, 3, 10);
    function my_breadcrumb_url_changer($url, $type, $id)
    {
    if(in_array(‘category’, $type) && (int) $id === MYCATID)
    {
    $url = get_permalink(PAGEID);
    }
    return $url;
    }
    ———————————————————
    This filter must be manually added on the page to the category mappings for each page<->category link we want to establish. Am I on the right track and can we reword your code like this? In that case, what would he look like if the logic is correct?

    Hello,

    The code you shared should be able to get the URL of the page you would like to be in the place of the category URL, but our filter requires additional work because we use an array to hold all the data for the breadcrumbs.

    On a normal breadcrumb, the data for the category is in the index 1 of the array $crumbs from our plugin, and that holds the name and the URL in a nested array.

    Our recommendation to get a working code snippet is to perform the following:

    1. Find the current category with the help of the array $crumbs[1] and store that in a variable.

    2. Perform the look-up with a snippet similar to what you shared in your reply to get the page that should be replaced with this one.

    3. Update the array $crumbs[1] with the new URL.

    Hope this helps get further along with this matter.

    Thank you.

    Hi, thanks for the detailed reply. The example you gave is very interesting and will be useful for sure. From your documentation on the matter, I get the impression that there is an easier way to replace the category archive with the parent page. Is there such a more automated way, eventually or?

    Hello,

    There is no automated way to replace the category archives with a page. You will have to create the page manually. You can check this tutorial to learn how to replace categories with a page: https://www.youtube.com/watch?v=5EkSj0nrCpg&t=1016s

    To replace the categories with pages in the breadcrumbs, please use the filter shared by my colleague. If you face any issues, let us know and we will assist you further.

    Looking forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘Different breadcrumbs’ is closed to new replies.