simple wp_insert_post example

// Create post object $my_post = array(); $my_post[‘post_title’] = ‘My post’; $my_post[‘post_content’] = ‘This is my post.’; $my_post[‘post_status’] = ‘publish’; $my_post[‘post_author’] = 1; $my_post[‘post_category’] = array(0); // Insert the post into the database wp_insert_post( $my_post );” This works fine. You code is correct, but it is an problem in the form to send the $_POST … Read more

How to rotate the header image per day?

<div id=”header”> <?php mt_srand((int)date(‘z’)); $headers=glob(PATH_TO_FILES .’/*.jpg’); $header=mt_rand(0,count($headers)-1 ); ?> <img id=”header-image” `src=”https://wordpress.stackexchange.com/questions/5232/<?php echo URL_TO_FILES .”https://wordpress.stackexchange.com/”.basename($headers[$header]); ?>” alt=”header” /> </div> replace your current header with this. I will of course help you implement this further if you need help. (or if you need the code explained)

page_template toggle between 2 templates + 2 permalinks for same post

WordPress has a simpler function for what you’re trying to do, add_rewrite_endpoint. Additionally, the filter for a single post template is single_template, page_template fires on the page post type. function wpd_detail_endpoint(){ add_rewrite_endpoint( ‘detail’, EP_PERMALINK ); } add_action( ‘init’, ‘wpd_detail_endpoint’ ); function wpd_detail_template( $template=”” ) { global $wp_query; if( ! array_key_exists( ‘detail’, $wp_query->query_vars ) ) return … Read more