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.

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.

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 *.

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

Latest From Divi Booster

Set Hover Color for Menu Links in the Divi Menu Module

Customizing the hover color of menu links lets you enhance the user experience and maintain visual consistency with your website’s brand. By setting a specific hover color, you can guide visitors' attention and improve navigation feedback. In this guide we show you...

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

Random Divi Posts