Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:41:15+00:00 2026-06-09T23:41:15+00:00

I have been trying to display this meta box info in my template as

  • 0

I have been trying to display this meta box info in my template as a table, but it isn’t working out.

What I want to do is make a simple table out of it. All I need is someone to help me start. The code for the meta box is done, but I have no idea how to output it.

$prefix = 'anime_';

$anime_box = array(
    'id' => 'anime-meta-box',
    'title' => 'Anime Details',
    'page' => 'post',
    'context' => 'normal',
    'priority' => 'high',
    'fields' => array(
        array(
            'name' => 'Name',
            'desc' => 'Add the name of the Anime in either English or Japanese(Romanji).',
            'id' => $prefix . 'anname',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Genre',
            'desc' => 'Is it a thriller, action/adventure, etc...',
            'id' => $prefix . 'angenre',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Directed by',
            'desc' => 'Name of director(s).',
            'id' => $prefix . 'an_director',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Music by',
            'desc' => 'Name of composer(s)',
            'id' => $prefix . 'anmusic',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Studio',
            'desc' => 'Studio which owns the anime.',
            'id' => $prefix . 'anstudio',
            'type' => 'text',
            'std' => ''
        ),
         array(
            'name' => 'Licensed by',
            'desc' => 'Name of both American and Japanese license holders.',
            'id' => $prefix . 'anlicense',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Network(s)',
            'desc' => 'Networks which air the show in both Japan and the United States.',
            'id' => $prefix . 'annetwork',
            'type' => 'text',
            'std' => ''
        ),
         array(
            'name' => 'Original run',
            'desc' => 'Date of when the anime first aired and when it stopped.',
            'id' => $prefix . 'anrun',
            'type' => 'text',
            'std' => ''
        ),
        array(
            'name' => 'Episodes',
            'desc' => 'Number of episodes.',
            'id' => $prefix . 'anepisodes',
            'type' => 'text',
            'std' => ''
        ),

    )
);

add_action('admin_menu', 'anime_add_box');

// Add meta box
function anime_add_box() {
    global $anime_box;

    add_meta_box($anime_box['id'], $anime_box['title'], 'anime_show_box', $anime_box['page'], $anime_box['context'], $anime_box['priority']);
}

// Callback function to show fields in meta box
function anime_show_box() {
    global $anime_box, $post;

    // Use nonce for verification
    echo '<input type="hidden" name="anime_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';

    echo '<table class="form-table">';

    foreach ($anime_box['fields'] as $field) {
        // get current post meta data
        $meta = get_post_meta($post->ID, $field['id'], true);

        echo '<tr>',
                '<th style="width:20%"><label for="', $field['id'], '"><strong>', $field['name'], ':</strong></label></th>',
                '<td>';
        switch ($field['type']) {
            case 'text':
                echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />',
                    '<br /><small>', $field['desc'],'</small>';
                break;

        }
        echo    '<td>',
            '</tr>';
    }

    echo '</table>';
}

add_action('save_post', 'anime_save_data');

// Save data from meta box
function anime_save_data($post_id) {
    global $anime_box;

    // verify nonce
    if (!wp_verify_nonce($_POST['anime_meta_box_nonce'], basename(__FILE__))) {
        return $post_id;
    }

    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }

    // check permissions
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return $post_id;
        }
    } elseif (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }

    foreach ($anime_box['fields'] as $field) {
        $old = get_post_meta($post_id, $field['id'], true);
        $new = $_POST[$field['id']];

        if ($new && $new != $old) {
            update_post_meta($post_id, $field['id'], $new);
        } elseif ('' == $new && $old) {
            delete_post_meta($post_id, $field['id'], $old);
        }
    }
}

I tried using

<table>
<tr>
<td><?php echo get_post_meta($post->ID, "anname", true); ?></td>
</tr>
</table>

As a way to test it out one field, but it hasn’t worked. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:41:17+00:00Added an answer on June 9, 2026 at 11:41 pm

    I believe the code you are using should be correct, however, the meta data ID you retrieving seems to be missing your prefix variable out: “anime_”. Try:

    <?php echo get_post_meta($post->ID, "anime_anname", true); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to figure this out for several hours but have had
I have been trying to work out the bug on this but can't seem
I have been trying to figure out a way to make this work, but
I have been trying to solve this problem all day but haven't got any
I have been trying to figure out how to display a background image behind
I have been trying to figure out this hoverintent plugin and its stumping me.
I have been trying to figure this out for 2 days and could not
I have been trying to display a folder list in Java using this code
I have been trying to display a MySQL table for some time and I
I have been trying to display my data in collection to the template. On

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.