Count custom post type based on two meta data

$args = array( ‘post_type’ => ‘appointments’, ‘meta_query’ => array( ‘relationship’ => ‘AND’, array( ‘key’ => ‘location’, ‘value’ => $place //set this somewhere ), array( ‘key’ => ‘timestamp’, ‘value’ => $time //set this somewhere ) ) ); $posts = new WP_Query( $args ); Docs: WP_Query You have the flexibility to add just about anything else you … Read more

Saving data for different custom posts

Since save_post gives you the post_id of the current post, you simply want to check what post_type it is by using get_post_type($post_id) like: add_action(‘save_post’, ‘save_details’) function save_details($post_id) { $post_type = $_REQUEST[‘post_type’]; if (‘foo_post’ == $post_type) { // save stuff for foo_post } elseif (‘bar_post’ == $post_type) { // save stuff for bar_post } } and … Read more

get_posts seems to be skipping the last Post

The default nmber of posts returned is 5. To return more than 5 posts use: $posts = get_posts( array(‘post_type’ => ‘events’, ‘numberposts’ => 10) ); Or for all of them: $posts = get_posts( array(‘post_type’ => ‘events’, ‘numberposts’ => -1) ); More info about get_posts http://codex.wordpress.org/Template_Tags/get_posts

Show Custom Message in WordPress Admin

add_action(‘admin_notices’, ‘my_custom_notice’); function my_custom_notice() { global $current_screen; if ( ‘my_post_type’ == $current_screen->post_type ) { echo “<h1>Whatever needs to be said</h1>”; } } Put this in your functions.php or plugin file. Replace ‘my_post_type’ with the name of your post type.