- This topic has 6 replies, 3 voices, and was last updated 6 years, 4 months ago by .
Viewing 6 reply threads
Viewing 6 reply threads
- The topic ‘Hide metabox/field if post has parent’ is closed to new replies.
Support Home » Topics » Piklist » Hide metabox/field if post has parent
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
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
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! 🙂
@mcmaster you are right, thank you. Sometimes i can think of the most unequivocal solutions.
@erikkubica, oh yes, I am also quite good at making my solutions more complex than the problems 🙂
Nice! Closing ticket.