WP Insert Post function – Insert Post Thumbnail

you need to first create the post and get the id: $postit = array( ‘post_title’ => $itemtitle, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_type’ => ‘items’, ‘post_author’ => $user_ID, ‘tags_input’ => $the_post_id ); $the_post_idit = wp_insert_post( $postit); Once you have the post id you can use update_post_meta( $the_post_idit,’_thumbnail_id’,$itemimage); just make sure that $itemimage holds the … Read more

Is it possible to have two different previews of a post (ie. two templates for one post)?

The easiest way to solve this is to create a special template file for previews, that will show the post twice in the different layouts. The following code will use the single-preview.php template file if it exists: add_filter( ‘single_template’, ‘wpse15770_single_template’ ); function wpse15770_single_template( $templates ) { if ( is_preview() ) { $templates = locate_template( array( … Read more

Function to show random posts from a category

cleaned up syntax errors: <?php function titoloslide() { query_posts(array( ‘orderby’ => ‘rand’, ‘category_name’ => ‘testimonianze’, ‘posts_per_page’ => 1 )); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class=”testimonianzefurgonihome”><a href=”#” title=”Testimonianze noleggio furgoni KobalRent”><?php the_excerpt(); ?></a></div> <?php endwhile; endif; wp_reset_query(); } ?>

Custom Theme Want To Remove One Category From All Displays

The only solution I could imagine is removing, rewriting, replacing the meta box. // First remove the original one function wpse21483_remove_catbox() { remove_meta_box( ‘post_categories_meta_box’, ‘post’, ‘side’ ); } add_action( ‘admin_menu’, ‘wpse21483_remove_catbox’ ); // not sure about the hook function wpse21483_new_catbox() { // re-define – take a look at /wp-admin/include/metaboxes.php } // Hook the new one … Read more