• Resolved jomarlipon

    (@jomarlipon)


    I have created a plugin which I include to create a page upon activation.

    How do I assign a page-template to the page which the page template is in plugin.

    I tried

    $testpage = array(
      'ID' => '100', //Are you updating an existing post?
      'page_template' => plugins_url( '/test.php', __FILE__ ), //Sets the template for the page.
      'comment_status' => 'closed', // 'closed' means no comments.
      'post_author' => '1', //The user ID number of the author.
      'post_name' => 'test', // The name (slug) for your post
      'post_status' => 'publish', //Set the status of the new post.
      'post_title' => 'Test Page',//The title of your post.
      'post_type' => 'page', //Sometimes you want to post a page.
    );

    which test.php is the page template file.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Assisn a page template upon plugin activation’ is closed to new replies.