我使用一种简单的方法将\\u post\\u meta()添加到wp\\u insert\\u post()。一切正常,除了我的元框没有出现在管理区。有没有简单的方法可以做到这一点?
<?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 );
SO网友:Rhyddwr
只需在自定义帖子中添加自定义字段支持;
register_post_type( \'YourPosts\',
array(
\'labels\' => array(
\'name\' => __( \'YourPosts\' ),
\'singular_name\' => __( \'YourPost\' )
),
\'public\' => true,
\'has_archive\' => true,
\'supports\' => array(
\'title\',
\'editor\',
\'custom-fields\',
)
)
);