Trying to perform complex custom field query with order by set to field value

If the value of your custom fields is numeric, you could try ordering with meta_value_num. Also note that both meta_value and meta_value_num require meta_key in the query as described here. $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => $number, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘meta_key’ => ‘event-start’, ‘value’ => $today_is, ‘type’ => ‘NUMERIC’, … Read more

Display Posts by modifying the where clause only for my query

If you’re going to add the filter on the where clause, then just make sure you remove it using remove_filter() and the exact same signature immediately after you create the query. In your example, you’re using query_posts(), so add the filter, run your query, and then remove your filter right afterward. add_filter( ‘posts_where’, ‘my_posts_where_filter’, 10, … Read more

WP_Query can’t exclude more than 1 author?

You are right, it is not possible to pass an array with author IDs to exclude them. The reason is in wp-includes/query.php at line 2294 – 2298 if ( strpos($q[‘author’], ‘-‘) !== false ) { $eq = ‘!=’; $andor=”AND”; $q[‘author’] = explode(‘-‘, $q[‘author’]); $q[‘author’] = (string)absint($q[‘author’][1]); // this line select the first ID and only … Read more

How to disable main query?

This is not trivial, because “home,category and search” are logically determined while main query churns through stuff. I am pretty sure I read this is possible, but that was in context of syndicating site that hadn’t used posts/loop at all and scrapped it to do different stuff. More typical approaches are: Integrate custom logic into … Read more

How to query for a week using key => value WP_Query argument notation?

There isn’t a week query variable, but there is w: http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters w (int) – Week of the year (from 0 to 53). Uses the MySQL WEEK command. The mode is dependent on the “start_of_week” option. Your args should look like this: $args = array(‘category_name’ => ‘whats-happening’, ‘year’ => 2012, ‘w’ => 46 ,’paged’ => $paged);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)