How to make search for the custom post type?

A better approach is to address the main search query. @Dipesh’s answer is technically correct, but I would suggest using the pre_get_posts action instead to affect the intial query, rather than generating a new one. Much less work! add_action( ‘pre_get_posts’, ‘se39294_search_pre_get_posts’ ); function se39294_search_pre_get_posts( $query ) { if ( $query->is_main_query() && is_search() ) { $query->set( … Read more

How to get future ID for post which haven’t been created yet?

You are on the correct path on thinking about post-edit.php. http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/post-new.php#L45 See how get_default_post_to_edit is called to return a new post. The second argument tells it to create a post in the database. The function is defined here: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-admin/includes/post.php#L394 Note line 422: $post_id = wp_insert_post( array( ‘post_title’ => __( ‘Auto Draft’ ), ‘post_type’ => $post_type, … Read more

Display all months with posts and inside each month show the 5 latest posts

one possibility is to run all posts through the loop and only output the month once per new month: <?php $counter = 0; $ref_month=””; $monthly = new WP_Query(array(‘posts_per_page’ => -1)); if( $monthly->have_posts() ) : while( $monthly->have_posts() ) : $monthly->the_post(); if( get_the_date(‘mY’) != $ref_month ) { if( $ref_month ) echo “\n”.'</ul>’; echo “\n”.'<h6>’.get_the_date(‘F’).'</h6>’; echo “\n”.'<ul>’; $ref_month … Read more