Shortcode creating two pages
-
I have the following shortcode created.
function add_contestant_function() { // Create post object $num = mt_rand ( 0, 0xffffff ); // created random number $idnum = sprintf ( "%06x" , $num ); // formats random number $newname = 'PC' . $idnum; // creates new contestant page from random number $newpass = 'MMV' . $idnum; // creates new contestant page from random number $my_post = array( 'post_title' => $newname, 'post_status' => 'publish', 'post_author' => $newname, 'post_type' => 'contestant' ); // Insert the post into the database wp_insert_post( $my_post ); ob_start(); ?> <p><b>This is your page ID : <?php echo $newname; ?> <p>This is your page PASSWORD : <?php echo $newpass; ?></b> <?php return ob_get_clean(); } add_shortcode('add_new_contestant', 'add_contestant_function');When it is added to a page it works as expected except that it creates two pages every time the page is accessed. I am not sure why. Please tell me what other information you may need to help me understand how to fix this.
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Shortcode creating two pages’ is closed to new replies.