Custom Post Type without author

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

Read More

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” } }

Related posts

Leave a Reply

1 comment