Plugin does not create page

Asked

Viewed 18 times

0

I’m trying to create page when activating a plugin, however, when trying to access, says that the page was not found, it even arrives without created, but gets a tag "scheduled" Follows code below:

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');

1 answer

0

Try to pass post_date_gmt together. 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',
);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.