How to get only present and past posts with post_date

You need to pass a strtotime() compatible string or an array instead of ‘today’. You have several options… You could change ‘today’ to ‘now’. This will use the current time not midnight last night. You could change ‘today’ to ‘today + 1 day’. This will be the end of today. Not exactly what you are … Read more

Select multiple categories with is_tax

Thanks to @SallyCJ for the correct answer — you can supply an array of category IDs/slugs/names to is_tax() to check for multiple categories. Here is the correct code: /* Hyde out of stock product specific category */ add_filter( ‘pre_get_posts’, ‘hide_out_of_stock_from_cat’ ); function hide_out_of_stock_from_cat( $query ) { if ( $query->is_tax( ‘product_cat’, array( 15, 16, 18, 19, … Read more

How to get the latest post list (of the parent custom custom type)

First off, adjust your query so you’re only returning top level posts (the parent posts in this instance) add_filter(‘pre_get_posts’, ‘only_top_level_posts’); function only_top_level_posts($query) { // wrap some conditional statements around here so it doesn’t affect every query, just limit to whatever queries you need it in $query->set( ‘post_parent’, 0 ); return $query; } This will return … Read more

How to get meta key list efficiently?

As mentioned in the comments you can query the postmeta table directly: public function get_metadata_keys(){ global $wpdb; $meta_query = $wpdb->get_results( ” SELECT DISTINCT meta_key FROM {$wpdb->postmeta} ” , ARRAY_A ); $meta_keys = wp_list_pluck( $meta_query, ‘meta_key’ ); return $meta_keys; } This will return the list of all meta_keys associated to any post.

use mysql variable in a $wpdb->query to reindex a column?

If I correctly understood, this is not possible (two queries instead of one). I ended up with this sad and time-consuming loop… :/ //get subtracks $querystr = $wpdb->prepare(“SELECT subtrack_id FROM `$subtracks_table` WHERE tracklist_id=’%d’ ORDER BY `subtrack_time` ASC”,$this->post_id); if ( !$ids = $wpdb->get_col($querystr) ) return; //update order $i = 0; foreach($ids as $id){ $i++; $wpdb->update( $subtracks_table, … Read more

WordPress – Form does not filter the results of taxonomies

Try below code for search using date and category. $_name = $_GET[‘date-picker-example’]; $categoria = $_GET[‘categoria_evento’]; $today = date(‘Ymd’); // Start the Query $v_args = array( ‘post_type’ => array(‘eventi-suite’), // your CPT ‘posts_per_page’ => -1, ‘meta_value’ => $_name, // looks into everything with the keyword from your ‘name field’ ‘order’ => ‘ASC’, ‘orderby’ => ‘metakey_AMC_data’, ‘meta_query’ … Read more