Query posts if meta key starts with

I figured it out: $the_query = new WP_Query(array( “numberposts” => -1, “post_type” => “plays_events”, “meta_query” => array( array( “key” => “show_times_%_date”, “value” => $this_month . “[0-9]{2}”, “compare” => “REGEXP” ) ), ));

Display most viewed post from last 30 days is not working correctly

Try this: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘meta_key’ => ‘post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’=> ‘ASC’, ‘date_query’ => array( array( ‘after’ => ’30 days ago’ ), ), ); $query = new WP_Query( $args ); You can’t directly order by met_key’s name, you need to use it the way it is above.

Temporarily storing main search result

The way I see it, you have three options: Store the global search data in $_SESSION Store the global data in a transient Run the query twice, with & without the post type filter I tried storing the array in a global variable and as soon as the page refreshes with the refined search results, … Read more

Get Posts that are in the current month or later

You can use meta_query, if you date information is saved in custom field. Like this: $args = array( ‘post_type’ => $custom_post_type, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘event_date_and_time’, ‘value’ => current_time(‘Ymd’), ‘compare’ => ‘>=’ ) ), ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); This code suppose you date is saved in YYYYMMDD … Read more

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