Follow us on

Codestar Support Forum » WordPress Plugins » Codestar Framework

Hide Metabox On Specific page

  1. Hello, Is it possible to hide metabox on specific pages? Specifically, I want to hide metaboxes on woocommerce default pages (Shop, cart, checkout, my account) and blog page. Can you give me an idea how can I do it?
    Thanks in advance.

    Posted 4 years ago #

  2. Codestar
    Admin

    Hi,

    Hmm, actually it is possible with a little custom code. for eg. I can give your this idea:

    function hide_metabox_in_woo_pages() {
    
      global $post, $post_type;
    
      if( class_exists( 'WooCommerce' ) && is_object( $post ) && $post_type === 'page' ) {
    
        $exclude   = array();
        $exclude[] = get_option( 'woocommerce_shop_page_id' );
        $exclude[] = get_option( 'woocommerce_cart_page_id' );
        $exclude[] = get_option( 'woocommerce_checkout_page_id' );
        $exclude[] = get_option( 'woocommerce_myaccount_page_id' );
    
        if( in_array( $post->ID, $exclude ) ) {
          echo '<style type="text/css">';
          echo '#YOUR_METABOX_UNIQUE_ID{ display: none !important; }';
          echo '</style>';
        }
      }
    
    }
    add_action( 'admin_head', 'hide_metabox_in_woo_pages' );CopyCopied!

    I am not sure it is works 100% but you can get the idea

    Regards, Codestar

    Posted 4 years ago #
  3. You are awesome.. your codes work fine. Thank you

    Posted 4 years ago #

  4. Codestar
    Admin

    You're welcome

    Posted 4 years ago #
  5. https://example.com/blog

    Can I hide meta box blog post page?

    Posted 1 year ago #

  6. Codestar
    Admin

    Hi @TwinkleTheme,

    Unfortunately, there is no option for this. You should write custom js for that.

    Regards, Codestar

    Posted 1 year ago #