Conditional posts in WP_query for search

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

$query->set( ‘post_type’, ‘post’ ); not working

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

Query Posts that have or don’t have a meta_value and order by the same ASC

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

Limiting a filtered query

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

Echo multiple tasks if a common function exists

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); } ?>

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