WP_Query Pagination

Hi @eeyore: Without being able to see the full context of your theme page I think you have at least two issues. You need to use $wp_query instead of $my_query if you want previous_posts_link() and next_posts_link() to work since they assume $wp_query. What @Jan Fabry mentioned; you need to capture the pagination yourself and pass … Read more

Is there a (preferable built-in) way to check what custom queries are used in a theme?

I don’t really understand what you’re trying to do, so here goes nothing: There are a lot of hooks within WP_Query. Most of them pass the current instance as one of the arguments. So, here’s how you could check for a “custom query”: function check_wp_query( $posts, $wp_query ) { if ( $wp_query->get(‘my_arg’) ) { // … Read more

Custom Post Type ‘Event’: Chronological list of recurring events from meta_values in array

Here’s the code that finally worked for me: <?php global $events_meta_termine; $today = getdate(); $my_query = new WP_Query(‘post_type=events&posts_per_page=-1&monthnum=’.$today[“mon”]); $events=array(); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; $meta = get_post_meta(get_the_ID(), $events_meta_termine->get_the_id(), TRUE); foreach ($meta[‘termin_group’] as $termin) { $event=array(); $event[‘title’]=get_the_title(); $event[‘date’]=$termin[‘termin_date’]; $event[‘time’]=$termin[‘termin_time’]; $event[‘location’]=$termin[‘termin_location’]; $events[]=$event; } endwhile; wp_reset_query(); $i=0; usort($events, “cmp”); function cmp($a, $b){ return strcmp($a[‘date’],$b[‘date’]); } ?> … Read more

Where is this query?

This looks like a query generated as part of the search facility within WordPress. For example, a visitor has been to your site and typed the word ‘true’ into your search box. If you have a large number of posts/pages/etc in your WordPress installation, then the only way you could optimise this query is to … Read more