Tag Info

Hot answers tagged

1

From the Codex: Multiple custom user fields handling $args = array( 'meta_query' => array( 'relation' => 'OR', 0 => array( 'key' => 'country', 'value' => 'Israel', 'compare' => '=' ), 1 => array( 'key' => 'age', 'value' => array( 20, 30 ), 'type' => ...


1

What else can I do to the query to do as little work as possible to eliminate "extra" posts in PHP that get queried because my query is too broad. The trouble is, meta queries are slow. Metadata is a simple key => value type database. Keys are indexed, and values are longtext. That's it. No datatypes. No additional indexes. Nothing. And not to mention ...


1

The parameter 'meta_query' is an array, so you can add multiple meta keys. In the doc, below the section "Example: Multiple Meta Entries - Multi dimensional array", you can find an example where the relation is set to 'OR': $query_args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'foo_key', // 'value' => 'foo', ...


1

You could use the 'posts_orderby' filter: function custom_loops($query) { if ( is_post_type_archive('my_post_type') ){ $query->set( 'posts_per_page', 40); $query->set( 'meta_key', 'custom_meta_sponsored'); $query->set( 'orderby', 'custom_meta_sponsored'); $query->set( 'order', 'DESC'); add_filter( ...



Only top voted, non community-wiki answers of a minimum length are eligible