|
/ Documentation /Custom Code Snippets/Astra Theme & Pro Filters/ Disable All Meta Settings of Page or Post by Default

Disable All Meta Settings of Page or Post by Default

Astra meta settings are page-specific settings. These settings allow you to disable Astra sections on a particular page/post.

You can find these by clicking on the Astra icon > Disable Elements.

In addition, you can disable all Astra meta settings on pages and posts by default (all boxes checked) by using a custom code.

This document provides the custom code to disable all Astra meta settings for pages and posts by default.

This approach can save you time and effort, especially when managing numerous pages or posts with minimal customization needs.

Disabling All Meta Settings by Default

Astra provides a solution to disable all meta settings by default for all new pages and posts. This functionality eliminates the need to revisit these settings for each content piece unless specific customization is required.

Here’s how to achieve this:

Note: Before you make any customizations, it’s a best practice to create a child theme to avoid affecting your main theme. If you already have a child theme, you can skip this step.

Now, you can follow these steps to disable all meta settings of the page/post by default.

Step 1: Access Your WordPress Dashboard

Log in to your WordPress admin dashboard. This is where you’ll be making the necessary changes to your theme’s settings.

Step 2: Open the Child Theme’s functions.php File

We recommend using Astra Pro’s Site Builder Hooks or a plugin such as WPCode/Code Snippets to add this code safely, since it won’t break your site if there’s a typo. If you’d rather edit the theme file directly, navigate to ‘Appearance’ > ‘Theme Editor,’ then find and click on the ‘functions.php’ file — but note that a small mistake here can cause a White Screen of Death, so please make sure you have a backup before proceeding.

Step 3: Insert the Code

Once you’re in the ‘functions.php’ file (or your code snippets plugin), carefully copy and paste the following code snippet exactly as shown. Even a small typo can cause errors on your site, so double-check before saving:

add_filter( 'astra_meta_box_options', 'default_disable_options' );

/**
* Default disable the Meta Options
*
* @param array $meta_option Page Meta.
* @return array
*/
function default_disable_options( $meta_option ) {

    $meta_option['ast-hfb-above-header-display'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['ast-main-header-display'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['ast-hfb-below-header-display'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['ast-hfb-mobile-header-display'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['footer-sml-layout'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['footer-adv-display'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['site-post-title'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['site-sidebar-layout'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['site-content-layout'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['ast-featured-img'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );
    $meta_option['ast-breadcrumbs-content'] = array(
            'default'  => 'disabled',
            'sanitize' => 'FILTER_DEFAULT',
    );

    return $meta_option;
}

Step 4: Save Your Changes

After inserting the code, make sure to save your changes by clicking the “Update File” button. This ensures that the modifications take effect on your website.

Step 5: Confirm It’s Working

Create a new draft page or post and click on the Astra icon > Disable Elements. You should see all the toggles switched off by default, confirming the code is working correctly.

If you’d like to reverse this change at any time, simply remove the code snippet you added and update the file again.

We hope this document has been helpful. Please feel free to leave a comment below if you have any queries.

Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Scroll to Top