0

I use a simple way to add_post_meta() to wp_insert_post(). Everything's working fine, except my meta box doesn't appear in admin area. Is there a simple way to do that?

<?php 
$condition = $_POST['condition']; // I am taking the field from my form and pass it to a variable
$pid = wp_insert_post($new_post); // $new_post is an array with my arguments
add_post_meta($pid, 'condition', $condition, true);
// Then i can display my meta box within post with echo get_post_meta( get_the_ID() , 'condition', true );
1

1 Answer 1

0

Just add custom-field support to your custom post;

register_post_type( 'YourPosts',
        array(
            'labels' => array(
                'name' => __( 'YourPosts' ),
                'singular_name' => __( 'YourPost' )
            ),
        'public' => true,
        'has_archive' => true,
        'supports' => array(
        'title',
        'editor',
        'custom-fields',
        )
        )
    );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.