Change Tab Order in Filterable Portfolio Module

Written by Dan Mossop

The Divi theme comes with a filterable portfolio module which lets you filter a list of projects by category. These category 'tabs' are sorted alphabetically by default.

Here's how the filterable portfolio looks in this case:

Changing the Filterable Portfolio Tab Order using Divi Booster

Divi Booster includes an option to change the order of the filterable portfolio module tabs. It can be found at:

Filterable Portfolio Settings > Design > Layout > Tab Order

Like so:

This option is available in Divi Booster v3.5.1 upwards.

Reverse Tab Order

To make the tabs display in reverse alphabetical order, set the Tab Order option to "Reverse":

Here's how the filterable portfolio looks in this case:

Random Tab Order

To make the tabs display in a random order each time, set the Tab Order option to "Random":

Here's how the filterable portfolio looks in this case:
Note that caching plugins may cause the same random order to be displayed each time. If this is undesirable, it can be solved by disabling caching on the page with the filterable portfolio.

Custom Tab Order (By Category Slug)

To make the tabs display in a custom order each time, set the Tab Order option to "By Slug". This will cause a new "Tab Order Slugs" option to appear. Entering a (comma-separated) list of category slugs here will cause the corresponding tabs to be displayed first, in the order given:

Note: You can find out the category slugs by going to "WP Dashboard > Projects > Categories".

Here's how the filterable portfolio looks in this case:

Move "All" Tab to the End

Normally the main "All" tab will be shown at the start, regardless of the order you set for the individual category tabs. If you'd like to move the "All" tab to the end instead, you can do it using the "All Tab Position" option:

 Here's how the filterable portfolio looks in this case:

 The "All Tab Position" option is available in Divi Booster v4.2.3 onwards

Set a Custom Tab Order using PHP

To display the filterable portfolio tabs in a custom order without using a plugin, you can add the following PHP code to your site:

$filter = (new DBCFilterablePortfolioTabsTermsFilter());
$filter->init();

class DBCFilterablePortfolioTabsTermsFilter {

    private $props;
    private $atts;

    public function init() {
        add_filter('et_pb_module_shortcode_attributes', array($this, 'add_terms_filter'), 10, 3);
        add_filter('et_module_shortcode_output', array($this, 'remove_terms_filter'));
    }

    public function add_terms_filter($props, $atts, $slug) {
        if ($slug !== 'et_pb_filterable_portfolio') return $props; 
        $this->props = $props;
        $this->atts = $atts;
        add_filter('get_terms', array($this, 'portfolio_tabs_filter'));
        return $props;
    }

    public function portfolio_tabs_filter($terms) {
        return apply_filters('dbc_filterable_portfolio_tabs_terms', $terms, $this->props, $this->atts);
    }

    function remove_terms_filter($content) {
        remove_filter('get_terms', array($this, 'portfolio_tabs_filter'));
        return $content;
    }
}

add_filter('dbc_filterable_portfolio_tabs_terms', 'dbc_sort_filterable_portfolio_tabs', 10, 3);

function dbc_sort_filterable_portfolio_tabs($terms, $props, $atts) {

    $tab_category_slugs = 'charlie,echo,bravo'; // <- *** REPLACE these with your category slugs ***

    if (!is_array($terms)) return $terms;
    $slugs = explode(',', $tab_category_slugs);
    $slugs = array_reverse($slugs);
    foreach($slugs as $slug) {
        $slug = trim($slug);
        foreach($terms as $k=>$term) {
            if (isset($term->slug) && $term->slug === $slug) {
                $terms = array($k=>$term) + $terms;
                break;
            }
        }
    }
    $terms = array_values($terms);
    return $terms;
}
It looks a lot but all you should need to do is replace the list of category slugs at the marked line in the above code with your own. Note that, unlike the Divi Booster option, the code above will affect all filterable portfolio modules on the site which include the specified categories.

We may earn a commission when you visit links on our website.

Effortlessly Manage Your Portfolio Tabs with Divi Booster

Enhance your Divi portfolio by customizing tab orders with Divi Booster. Now you can easily reverse, randomize, or set a custom order for your filterable portfolio tabs. Perfect for showcasing your projects just the way you want.

Latest Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

6 Comments

  1. Hi, I've just bought the Divibooster extension in order to resolve this issue : I'm searching for order the tab as I want from slugs. I've installed it but the modifications I've did aren't active. An idea?

    Reply
    • Hi Caroline, the first thing to try, if you haven't already, is clearing your caches in case an old version of the page is shown. If that doesn't help, would you be able to share a link to the page you're working on so that I can look into it for you? Thanks!

      Reply
  2. Thank you for this information. I wonder: is it also possible to put 'all' at the end of 'Custom Tab Order (By Category Slug)?

    Reply
    • Hey Hanneke, I've just updated Divi Booster (v4.2.3) with an option to move the 'all' tab to the end. I've added a section to the end of this post with details. I hope it helps, but let me know if you have any questions about it. Cheers!

      Reply
  3. Great overview of all the functionality Divi Booster entails thank you. I didn't realize how much it actually included easily worth the price.

    Reply
    • You're very welcome, Jeff. Thanks!

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.