Random posts in WP_Query when searching by tag
tag_slug__in should be an array, not a string, that is why your query fails ‘tag_slug__in’ => [‘featured’], // Requires PHP 5.4+, use array( ‘featured’ ) pre 5.4
tag_slug__in should be an array, not a string, that is why your query fails ‘tag_slug__in’ => [‘featured’], // Requires PHP 5.4+, use array( ‘featured’ ) pre 5.4
What about removing the if statement, and combining the queries into something like this: ‘meta_query’, array( ‘relation’ => ‘OR’, array( array( ‘relation’ => ‘AND’, array( ‘key’ => ‘am_get_recurring_count’, ‘compare’ => ‘=’, ‘value’ => ‘0’, ), array( ‘relation’ => ‘OR’, array( ‘key’ => ‘am_enddate’, ‘compare’ => ‘>=’, ‘value’ => $currentdate, ), array( ‘key’ => ‘am_enddate’, ‘compare’ … Read more
After Milo’s help I found a function where it altered the search query: if( is_search() && empty($_GET[‘post_type’]) && !is_admin() ) { global $wpdb; $query = get_search_query(); $query = $wpdb->esc_like( $query ); $where .= ” OR {$wpdb->posts}.ID IN (“; $where .= “SELECT {$wpdb->postmeta}.post_id “; $where .= “FROM {$wpdb->posts}, {$wpdb->postmeta} “; $where .= “WHERE {$wpdb->posts}.post_type=”page” “;<-page to … Read more
You can do this by naming index of meta query, then passing array of these names in orderby parameter $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ’10’, ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘with_time’ => array( ‘key’ => ‘TIME_meta_key’, ‘compare’ => ‘EXISTS’ ), ‘without_time’ => array( ‘key’ => ‘TIME_meta_key’, ‘compare’ => … Read more
Use $wpdb->get_results with filter based on array
I noticed that the problem was related that one custom field was a taxonomy, so, as I was using the archive page for that custom post type, I only needed to filter the query looking for the date limits. $fecha_actual = current_time(‘Ymt’); //t regresa el ultimo día del mes $fecha_anterior = date(‘Ymd’, strtotime(“first day of … Read more
You can order posts by meta value check out the codex https://codex.wordpress.org/Class_Reference/WP_Query
As @Howdy_McGee mentioned in the comments, you can just wrapped the multiple commands you want to run within curly brackets like this: <?php if (function_exists (‘pluginName’)) { echo someName (7); echo someName (8); echo someName (9); } ?>
Figured this out. ‘order’ => ‘ASC’ (or DESC – however you’d like) and ‘orderby’ => ‘menu_order’ solves this.
ok, I was close and I have solution: SELECT wp_posts.ID, wp_postmeta.meta_value FROM wp_postmeta INNER JOIN wp_posts ON wp_posts.ID = wp_postmeta.post_id INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) WHERE 1=1 AND wp_postmeta.meta_key = ‘_application’ AND ( wp_term_relationships.term_taxonomy_id IN (31) AND tt1.term_taxonomy_id IN (14) )