Pull Two Posts Into Custom Post Type `single-cpt.php`

Try this: <?php $current_id = get_the_ID(); $next_post = get_next_post(); $next_id = $next_post->ID; $cpt = get_post_type(); $cpt_array = array($current_id, $next_id); $args = array( ‘post_type’ => $cpt, ‘post__in’ => $cpt_array, ‘order_by’ => ‘post_date’, ‘order’ => ‘ASC’, ); $the_query = new WP_Query($args); if($the_query->have_posts()): while($the_query->have_posts() ): $the_query->the_post(); echo ‘<h2>’.the_title().'</h2>’; endwhile; endif; wp_reset_postdata(); ?> Tested locally and seems to work … Read more

Forcing all posts associated with a custom post type to be private

You can hook onto save_post, wp_insert_post or wp_insert_post_data to modify the post object prior to it being inserted or saved. Using save_post or wp_insert_post the callback would need to declare two args and would receive the post object as the second incoming variable.. (and i’m showing you to cover the alternatives, TheDeadMedic’s example would be … Read more

Display text if current user has written 1 or more posts in a custom post type

Hi @Carson: A simple function to address what you are asking for might be the function yoursite_user_has_posts() which leverages the built in WP_Query class: function yoursite_user_has_posts($user_id) { $result = new WP_Query(array( ‘author’=>$user_id, ‘post_type’=>’any’, ‘post_status’=>’publish’, ‘posts_per_page’=>1, )); return (count($result->posts)!=0); } You can then call it from your theme like this: <?php $user = wp_get_current_user(); if ($user->ID) … Read more

jQuery UI in Admin (Best Practice?)

WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait. Also, it sounds like you’re outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own. This is done using wp_deregister_script() and wp_enqueue_script().