Add a page to wordpress -


i'm in process of building own wordpress plugin.so need create new page(or post) automatically added word press when plugin activated.and removed when plugin deactivated.content in page content typing in plugin. how can that?

you can use wp_insert_post function create page or post check http://codex.wordpress.org/function_reference/wp_insert_post

ex.

// create post object $my_post = array(   'post_title'    => 'my post',   'post_content'  => 'this post.',   'post_status'   => 'publish',   'post_author'   => 1,   'post_category' => array(8,39) );  // insert post database $post_id = wp_insert_post( $my_post); 

you can use $post_id withing add_post_meta or update_post_meta or use post_meta varible install , uninstall page.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -