How to get user avatar via WPDB
How to get user avatar via WPDB
How to get user avatar via WPDB
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
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
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
This if statement is preventing you to use category-1.php template for the parent categories: if( 0 < $cat->category_parent ) Parent (top level) categories always have a $cat->category_parent === 0. Remove that statement and try again, to see if this is the result you want to achieve. Other than that, I am not really sure I … Read more
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.
Where my home page and font options has gone?
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
For the above function this would work: $children = get_all_subpages($cat_id, $args, OBJECT); foreach ($children as $post) { echo $post->guid; echo $post->post_title; }
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