Skip to content

Snippet: Add New Custom “Access” Options for WPBakery

The Total theme includes an exclusive "Access" option in certain WPBakery elements such as Sections and Rows which allows you to display the elements only if the selected access is true. The default access options include "Logged in" and "Logged out" but what if you needed a custom check? It's really easy to add custom Access options! The example shows how you can add a custom access so that the content will only display if the current post is in the "news" category.

The first portion of the code is used to register your custom access option which hooks into the "totaltheme/restrict_content/restrictions" filter which returns an array of whitelisted functions for checking custom access/restrictions.

The second portion of the code is the callback function that runs when the specific access is selected. This function should return a boolean and it should be named exactly the same as it's registration in the previous code.

// Add new restrictions.
add_filter( 'totaltheme/restrict_content/restrictions', function( array $restrictions ): array {
    $restrictions[] = 'myprefix_restrict_content_to_news_category';
    return $restrictions;
} );

// Custom restriction callback function. 
function myprefix_restrict_content_to_news_category(): bool {
    $check = false;

    // Display content if the post is in the category 'news'
    if ( in_category( 'news' ) ) {
        $check = true;

    return $check;
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top