How can I combine meta_query queries?

Using your constructed array, I think this is the correct syntax: $meta_query_args = array( ‘meta_key’ => ‘price’, ‘meta_value_num’ => 1000, ‘meta_compare’ => ‘<=’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘roomcount’, ‘value’ => 3, ‘type’ => ‘numeric’, ‘compare’ => ‘>=’ ), array( ‘key’ => ‘bathroomcount’, ‘value’ => 2, ‘type’ => ‘numeric’, ‘compare’ => … Read more

Add a default meta_value to new posts

Add this to your functions.php in your template folder. <?php //Set Default Meta Value function set_default_meta_new_post($post_ID){ $current_field_value = get_post_meta($post_ID,’YOURMETAKEY’,true); //change YOUMETAKEY to a default $default_meta=”100″; //set default value if ($current_field_value == ” && !wp_is_post_revision($post_ID)){ add_post_meta($post_ID,’YOURMETAKEY’,$default_meta,true); } return $post_ID; } add_action(‘wp_insert_post’,’set_default_meta_new_post’); ?>

WordPress custom archive page

Of course it breaks. Pagination depends on the main query saved in the $wp_query object and you have overwritten that. When the next page load the ordinary wp_query that you have not overwritten will run and it won’t match the one you’ve altered. Create a filter for pre_get_posts to alter the main query. function pregp_wpse_97354($qry) … Read more

Display Posts of a Category in Alphabetical Order (Custom Post Type)

Use the pre_get_posts action to modify the query before it is run. Place this in your theme’s functions.php: function wpd_tax_alpha( $query ) { if ( $query->is_tax(‘link-category’) && $query->is_main_query() ) { $query->set( ‘orderby’, ‘title’ ); $query->set( ‘order’, ‘ASC’ ); } } add_action( ‘pre_get_posts’, ‘wpd_tax_alpha’ );

posts order by title second word

The simplest method may be to just save titles as last name / first name, then they will naturally sort. You can then reverse the title when you output it in the template. Your attempt to modify the orderby query var is fundamentally flawed. Order is created by MySQL, which doesn’t understand PHP, and can’t … Read more