Fastest way to get the comment and ping total count for a post

you can use this custom function in the functions.php of the theme: /** * count for trackback, pingback, comment, pings * * embed like this: * fb_comment_type_count(‘pings’); * fb_comment_type_count(‘comment’); */ if ( !function_exists(‘fb_comment_type_count’) ) { function fb_get_comment_type_count( $type=”all”, $zero = false, $one = false, $more = false, $post_id = 0) { global $cjd_comment_count_cache, $id, $post; … Read more

How do I get the title of a category in a custom loop?

Since you already have the category ID (you use it in your call to WP_Query::query()), you can just use that to request the category name. get_cat_name( $cat_id ) will do exactly that. It uses get_category( $cat_id ) in the background, which returns the full category object, which can be useful if you want to show … Read more

Using ajax with paging and a custom sub-query

Two options- load a page fragment using jQuery’s load method (see Loading Page Fragments), or create your own ajax function to load posts and return it in whatever markup you wish: add_action(‘wp_ajax_my_ajax_get_posts’, ‘my_ajax_callback’); add_action(‘wp_ajax_nopriv_my_ajax_get_posts’, ‘my_ajax_callback’); function my_ajax_callback() { $args = $_POST[‘myargs’]; $collected_child_posts = new WP_Query($args); echo ‘some stuff’; die(); } pass the admin-ajax url to … Read more

Search breaks when querying main loop for category

For your second example, I think you’re initiating your Loop incorrectly. You’re declaring $query, which hasn’t been globalized? // Search is working, querying is not global $query_string; // required $posts = query_posts($query_string.’&posts_per_page=3&cat=$catid’); while ( $query->have_posts() ) : $query->the_post(); Try omitting $query from your Loop initiation? // Search is working, querying is not global $query_string; // … Read more

Display upcoming Events for next 7 Days

I haven’t had much success in the past using the BETWEEN comparison with meta queries. You might have better luck by replacing your meta query with a >= and <= comparison: ‘meta_query’ => array( array( ‘key’ => ‘opening_time’, ‘value’ => $today, ‘compare’ => ‘>=’, ‘type’ => ‘DATE’ ), array( ‘key’ => ‘opening_time’, ‘value’ => $future, … Read more