Custom Fields
Support General Get the POST ID when defining a metabox

  • Creator
  • #18542
    Resolved elindydotcom


    In core WP, the filter for defining a metabox gives us the POST ID so we can use data from the post to determine whether or not to even paint the metabox.

    In METABOX.IO I can’t seem to find a way to get to the POST data while defining the metabox. I want to look at some field values on the post to determine whether or not to even show the entire metabox in the first place.

    Can someone point me to how that might be accomplished? I’ve looked at the conditional add-ons but they don’t seem to do the trick as far as I can tell.


Viewing 1 replies (of 1 total)
  • Author
  • #18574
    Anh Tran


    You can get the post ID with the following code:

    $post_id = null;
    if ( isset( $_GET['post'] ) ) {
        $post_id = intval( $_GET['post'] );
    } elseif ( isset( $_POST['post_ID'] ) ) {
        $post_id = intval( $_POST['post_ID'] );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash