Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // TO DO WHEN THEME IS ACTIVATED ///////////////////////
- if (isset($_GET['activated']) && is_admin()){
- function create_frontles_posts() {
- $x = 1;
- do {
- //creating a blank array to store the inserted terms ids
- $terms = array();
- $tax_insert_id = wp_insert_term('mosaic-home','tiles_categories' );
- $terms[] = $tax_insert_id['term_id'];
- //Creating a post array
- $post = array(
- 'comment_status' => 'closed',
- 'ping_status' => 'closed',
- 'post_author' => 1,
- 'post_name' => 'tile'.$x,
- 'post_title' => 'Tile',
- 'post_status' => 'publish',
- 'post_type' => 'frontiles',
- );
- //Inserting the post in WordPress using wp_insert_post()
- //if the post is successfully posted, post_id is returned and stored in $the_post_id
- $the_post_id = wp_insert_post( $post );
- //assign the terms stored in $terms array to $the_post_id post
- wp_set_post_terms( $the_post_id, $terms, 'tiles_categories' );
- $x++;
- } while ($x <= 24);
- }
- function programmatically_create_post() {
- // Initialize the page ID to -1. This indicates no action has been taken.
- $post_id = -1;
- $title=' ';
- // If the page doesn't already exist, then create it
- if( null == get_page_by_title( $title ) ) {
- create_frontles_posts();
- } else {
- // Otherwise, we'll stop
- $post_id = -2;
- }
- }
- add_filter( 'after_setup_theme', 'programmatically_create_post' );
- } // end action on activation theme
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement