Title: Breadcrumbs level limit
Last modified: April 21, 2021

---

# Breadcrumbs level limit

 *  Resolved [rafaviana](https://wordpress.org/support/users/rafaviana/)
 * (@rafaviana)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/)
 * Hi,
    Is it possible to set a page level limit for breadcrumbs? I have some pages
   where I don’t want to show all the parent categories:
 * I this:
    ROOT PAGE > PARENT CATEGORY > CATEGORY > SUB-CATEGORY > PAGE
 * I want this:
    ROOT PAGE > PARENT CATEGORY > CATEGORY > PAGE
 * Is it possible to set a limit of 2 pages (parent category and category) ?

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

 *  Plugin Author [John Havlik](https://wordpress.org/support/users/mtekk/)
 * (@mtekk)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/#post-14367966)
 * Well, there are a couple of ways you could achieve this. Using something like
   Order Bender to set a preferred category, and setting that to be the 2nd level
   category for each applicable post is one way of achieving this result. You could
   hook into the `bcn_after_fill` action, go through the breadcrumbs array and removing
   category breadcrumbs after there have been 2 (see [https://mtekk.us/archives/guides/conditionally-remove-home/](https://mtekk.us/archives/guides/conditionally-remove-home/)
   for an example of removing a breadcrumb from the breadcrumb trail, you will just
   need more logic for figuring out what breadcrumb to remove).
 *  Thread Starter [rafaviana](https://wordpress.org/support/users/rafaviana/)
 * (@rafaviana)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/#post-14369028)
 * Hi, I really appreciate your help. I took a look into the documentation but I
   don’t have the proper skills to write that code.
 * How can I go through the breadcrumbs array to remove category breadcrumbs after
   there have been 2 ?
 *  Plugin Author [John Havlik](https://wordpress.org/support/users/mtekk/)
 * (@mtekk)
 * [5 years ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/#post-14445513)
 * The below code, in theory, probably does what you want. Note that I have not 
   tested it so there may be a PHP warning/error message lurking in there.
 *     ```
       add_action('bcn_after_fill', 'my_only_two');
       function my_only_two($trail)
       {
          if(count($trail->breadcrumbs) > 4)
          {
             $breadcrumbs = $trail->breadcrumbs;
             krsort($breadcrumbs);
             $cat_count = 0;
             foreach($breadcrumbs as $key => $breadcrumb)
             {
                if(in_array('category', $breadcrumb->get_types()))
                {
                   $cat_count++;
                   if($cat_count >2)
                   {
                      unset($trail->breadcrumbs[$key]);
                   }
                }
             }
          }
       }
       ```
   
 *  Thread Starter [rafaviana](https://wordpress.org/support/users/rafaviana/)
 * (@rafaviana)
 * [5 years ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/#post-14451747)
 * Hi! It works perfectly. I just had to change the custom post type ‘category’ 
   to my custom post type slug ‘dt_portfolio_category’
 * Thank you

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

The topic ‘Breadcrumbs level limit’ is closed to new replies.

 * ![](https://ps.w.org/breadcrumb-navxt/assets/icon.svg?rev=1927103)
 * [Breadcrumb NavXT](https://wordpress.org/plugins/breadcrumb-navxt/)
 * [Support Threads](https://wordpress.org/support/plugin/breadcrumb-navxt/)
 * [Active Topics](https://wordpress.org/support/plugin/breadcrumb-navxt/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/breadcrumb-navxt/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/breadcrumb-navxt/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [rafaviana](https://wordpress.org/support/users/rafaviana/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/breadcrumbs-level-limit/#post-14451747)
 * Status: resolved