Viewing 6 reply threads
  • Author
    Posts
    • #4435
      erikkubica
      Member

      Hi,

      I am trying to achieve to hide 10 fields if page has parent. Currently condition
      array(
      “field” => “parent_id”,
      “value” => “”
      )

      is not working.

      So if any way exists that i have not found in documentation please…

      Thankyou

    • #4467
      mcmaster
      Member

      I think the simplest way is to enclose the field definition in an “if” statement.

      if ( $post->post_parent ) {
          // define fields here
      }

      You may need to declare $post as a global.
      global $post;

      Donna

    • #4468
      Steve
      Keymaster

      @erikkubica


      @mcmaster
      is right. That’s the beauty of Piklist and the fact that it’s code based… you can use normal PHP conditional statements.

    • #4469
      mcmaster
      Member

      Thanks, @Steve. But I just realized I got it backwards. I think @erikkubica wants:

      if ( !$post->post_parent ) {
          // define fields here
      }

      It’s those details that always bite me! 🙂

    • #4471
      erikkubica
      Member

      @mcmaster you are right, thank you. Sometimes i can think of the most unequivocal solutions.

    • #4472
      mcmaster
      Member

      @erikkubica, oh yes, I am also quite good at making my solutions more complex than the problems 🙂

    • #4484
      Steve
      Keymaster

      Nice! Closing ticket.

Viewing 6 reply threads
  • The topic ‘Hide metabox/field if post has parent’ is closed to new replies.