Post id within the register metabox

Support General Post id within the register metabox

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2151
    ClementNClementN
    Participant

    Hello,

    Can you please advice how I can get the Post ID within the function lp_register_meta_boxes( function .

    I tried
    global $post;
    $id = $post->ID;

    But this doesn't seem to work..

    In fact, I need to get a field value (already stored) for the same post id the metabox is registered for .

    I tried rwmb_meta() but it doesn't work without post id.

    Thank you very much,

    Portion of the code

    global $post;
    $post_id = $post->ID;
    $event_tracks = rwmb_meta( 'event_tracks', 'type=select', $post_id );

    $meta_boxes[] = array(
    'id' => 'event_timeline',
    'title' => 'Event Timeline .. ' . $event_tracks,

    .................

    #2154
    Anh TranAnh Tran
    Keymaster

    You can use this simple code:

    $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : false );

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Post id within the register metabox’ is closed to new replies.