SQL error with custom query

Should be: $where .= ” AND voted > 1″; Other notes: instead of hardcoding table names you should use $wpdb->prefix . ‘post_votes’; instead of checking in global $_GET you should declare your filters as accepting two arguments and code functions accordingly, these filters pass as second argument object that contains all of query data. Like: … Read more

Custom Field Date Problem

I agree with Denis, I don’t like using custom fields for this kind of stuff, but I’m not aware of any other way yet… What you what can be done by altering the SQL query for the loop, something like this: add_filter(‘posts_join’, ‘my_post_filter_join’); function my_post_filter_join($join) { global $wpdb; if(is_home() || is_category() || is_search()) $join .= … 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

Problem on displaying the results on my query

You need to use WordPress meta query: Display posts where the custom field key is ‘extra1’ and the custom field value is ‘test’: $query = new WP_Query( array( ‘meta_key’ => ‘extra1’, ‘meta_value’ => ‘test’ ) ); For more info take a look at WP Query Custom_Field_Parameters.