Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress : Help with displaying data from custom meta boxes

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #39494
    gilgimech
    Participant

    I’ve made some custom meta boxes, but I can’t get the info to display outside the loop.
    I’ve tried using this but I get nothing


    global $post;
    $args = array('post_type' =>'post-type');
    $meta = get_post_meta($post->ID, 'meta-box-slug', true);
    wp_reset_query();

    And I’ve tried this too


    global $post;
    $args = array('post_type' => 'post-type');
    $obituary_query = new WP_Query($args);
    while ($obituary_query->have_posts()) : $obituary_query->the_post();
    $meta = get_post_meta($post->ID, 'meta-box-slug', true);
    echo $meta;
    endwhile;
    wp_reset_query();

    That does displays the data but it throws a “Headers already sent error”

    I’m not sure what I’m doing wrong. I haven’t had much luck working with custom meta boxes.

    Thanks in advance.

    #108394
    chrisburton
    Participant

    Are you using a plugin?

    #108395
    gilgimech
    Participant

    No, but I may just be stupid. I just thought of something. I’ll let you know if it works.

    #108397
    gilgimech
    Participant

    OK, yeah I’m stupid. For some reason, I was got it in head that I had to work outside the loop.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.