Plugin does not create page

0

I'm trying to create a page by activating a plugin, but when it tries to access it, it says the page was not found, it even arrives without a host, but it gets a "scheduled" tag.

function projetos()
  {

    $post = array(
          'comment_status' => 'open',
          'ping_status' =>  'closed' ,
          'post_date' => date('Y-m-d H:i:s'),
          'post_name' => 'Projeto',
          'post_status' => 'publish' ,
          'post_title' => 'Ver Projeto',
          'post_type' => 'page',
    );

    $newvalue = wp_insert_post( $post, false );
    update_option( 'proj-pages', $newvalue );
  }

register_activation_hook( __FILE__, 'projetos');
    
asked by anonymous 04.07.2017 / 14:21

1 answer

0

Try to pass post_date_gmt along. Strange things happen without this parameter:

$time = time();

$post = array(
      'comment_status' => 'open',
      'ping_status' =>  'closed' ,
      'post_date' => date('Y-m-d H:i:s', $time),
      'post_date_gmt' => gmdate('Y-m-d H:i:s', $time),
      'post_name' => 'Projeto',
      'post_status' => 'publish' ,
      'post_title' => 'Ver Projeto',
      'post_type' => 'page',
);
    
05.07.2017 / 13:05