Viewing 3 reply threads
  • Author
    Posts
    • #3764
      kattagami
      Member

      Hi,

      I would like to know if there is a way to disable a metabox with a line of code?

      For instance, in a Custom Post Type, I have two metaboxes.
      In each of these metaboxes, I would like to start my code by testing a condition and if this condition is “false”, then disable the current metabox.

      Thanks

    • #3804
      Steve
      Keymaster

      @kattagami

      Sorry for the late reply.

      You can do this with the beta, which I believe you have.

      Here’s a very simple example. This code will disable any meta-box with the name “Text Fields”.

      function my_disable_metabox($part_data, $folder)
      {
        if (isset($part_data['title']) && $part_data['title'] == 'Text Fields')
        {
          return;
        }
      
        return $part_data;
      }
      add_filter('piklist_part_add','my_disable_metabox', 10, 2);
      
    • #3820
      kattagami
      Member

      Thanks Steve, you are amazing 🙂

    • #3821
      Steve
      Keymaster

      @kattagami– We really appreciate your support of Piklist.

      Closing ticket.

Viewing 3 reply threads
  • The topic ‘Disable a metabox’ is closed to new replies.