Let user change posts per page

This is may not be the best solution, but it works. Following code needs to be added in functions.php. add_filter(‘query_vars’, ‘parameter_queryvars’ ); // Let WP accept the query argument we will use function parameter_queryvars( $qvars ) { $qvars[] = ‘posts_per_page’; return $qvars; } add_action( ‘pre_get_posts’, ‘change_post_per_page’ ); // Filter posts based on passed query variable … Read more

Tracing the life of a query

Well you can try and run debug_backtrace(); on your function. For example: function wpse_82183_debug( $query ) { //your query goes here, this is just a basic one if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘posts_per_page’, 1 ); //magic happens here var_dump(debug_backtrace()); } } add_action( ‘pre_get_posts’, ‘wpse_82183_debug’ ); There are also a number of plugins … Read more

Extending the site search to include a single custom field

I managed to resolve by extending the query function extend_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search )) return $search; $terms = $wp_query->query_vars[ ‘s’ ]; $exploded = explode( ‘ ‘, $terms ); if( $exploded === FALSE || count( $exploded ) == 0 ) $exploded = array( 0 => $terms ); $search=””; foreach( … Read more