Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically create page in WordPress

Tags:

wordpress

How can I automatically create a WordPress page (for example, when plugin is activated)?

like image 764
Phil Avatar asked Jul 27 '09 01:07

Phil


People also ask

How do I create a nest page in WordPress?

You can enable nested pages for any default or custom post types in WordPress. Simply visit Settings » Nested Pages in the WordPress admin and click on the 'Post Types' tab. Next, just select the post types where you want to enable nested pages functionality and then save your changes.

How do I create a simple coming soon page in WordPress?

To set your site to Coming Soon, go to Manage in the sidebar, select Settings, scroll down to Privacy, and select the Coming Soon button. Be sure to click on Save settings for the change to take effect. While in this mode, site visitors will see a landing page with your site's title.

How do I use WordPress automatically?

Step 1: Download and Install the WordPress Automatic Plugin After Downloading the Plugin you need to install Scraper, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New. Click Upload and choose plugin zip file from your computer, then click Install Now and you're done.


1 Answers

Use wp_insert_post(), which can insert pages as well: http://codex.wordpress.org/Function_Reference/wp_insert_post

See post_type below.

$post = array(
  'ID' => [ <post id> ] //Are you updating an existing post?
  'menu_order' => [ <order> ] //If new post is a page, sets the order should it appear in the tabs.
  'page_template' => [ <template file> ] //Sets the template for the page.
  'comment_status' => [ 'closed' | 'open' ] // 'closed' means no comments.
  'ping_status' => [ ? ] //Ping status?
  'pinged' => [ ? ] //?
  'post_author' => [ <user ID> ] //The user ID number of the author.
  'post_category' => [ array(<category id>, <...>) ] //Add some categories.
  'post_content' => [ <the text of the post> ] //The full text of the post.
  'post_date' => [ Y-m-d H:i:s ] //The time post was made.
  'post_date_gmt' => [ Y-m-d H:i:s ] //The time post was made, in GMT.
  'post_excerpt' => [ <an excerpt> ] //For all your post excerpt needs.
  'post_name' => [ <the name> ] // The name (slug) for your post
  'post_parent' => [ <post ID> ] //Sets the parent of the new post.
  'post_password' => [ ? ] //password for post?
  'post_status' => [ 'draft' | 'publish' | 'pending' ] //Set the status of the new post.
  'post_title' => [ <the title> ] //The title of your post.
  'post_type' => [ 'post' | 'page' ] //Sometimes you want to post a page.
  'tags_input' => [ '<tag>, <tag>, <...>' ] //For tags.
  'to_ping' => [ ? ] //?
);  

// Insert the post into the database
wp_insert_post( $post );
like image 144
Artem Russakovskii Avatar answered Nov 04 '22 17:11

Artem Russakovskii