I’m inserting information into a new post, and when I use var_dump, I don’t see no author ID, and because of that, I can’t retrieve it later.
global $user_ID;
$new_post = array(
'post_title' => $_POST['titulo_necessidade'],
'post_content' => $_POST['conteudo_necessidade'],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'necessidade',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);
var_dump(get_post_meta($post_id));
The result I get is the following
array(3) { [“titulo_necessidade”]=> array(1) { [0]=> string(7) “tyktyuk” } [“conteudo_necessidade”]=> array(1) { [0]=> string(7) “tkyutut” } [“submit_necessidade”]=> array(1) { [0]=> string(6) “Enviar” } }
Check if while registering custom post type
register_post_type
You specifyauthor
as supported.More info about custom post types: http://codex.wordpress.org/Function_Reference/post_type_supports