How to query wordpress with array of meta_values?
How to query wordpress with array of meta_values?
How to query wordpress with array of meta_values?
How to break up output of posts for different terms on same page?
It seems you are confusing actions and filters here. You are using an action. That means if you want to output some html you have to that inside the function. Now your are returning the value, but nothing is done with it. So in the last line of your function you should have echo $title_yama … Read more
I can see in your code you did mistakes with meta key arguments. You must use underscore instead of hyphen sign. Here is corrected code: $args = array( ‘number’ => 5 , ‘meta_key’ => ‘post_count’, ‘meta_value’ => 10, ‘meta_compare’ => ‘>’, ‘orderby’ => ‘rand’ ); $user_query = new WP_User_Query( $args ); if ( ! empty( … Read more
I tried this code and it should work for you In your function.php to make random order available in WP_User_Query function my_random_user_query( $class ) { if( ‘rand’ == $class->query_vars[‘orderby’] ) $class->query_orderby = str_replace( ‘user_login’, ‘RAND()’, $class->query_orderby ); return $class; } add_action( ‘pre_user_query’, ‘my_random_user_query’ ); Source And a query like this // Get all users id … Read more
WP_Query defaults to getting posts, not pages. From the above reference page: Display content based on post and page parameters. Remember that default post_type is only set to display posts but not pages. This code: // WP_Query arguments $args = array( ‘post_parent’ => ‘4117’, ‘post_type’ => ‘page’, ‘posts_per_page’ => ‘1’, ‘order’ => ‘DESC’, ‘orderby’ => … Read more
WP_Query is not a general-purpose method for querying the database. It’s specifically designed for querying posts with the intention to loop over them and output templates for them. If you just want arbitrary data from the wp_posts table, then you can just write SQL and use the $wpdb object to run it: $query = $wpdb->prepare( … Read more
Sort posts on custom field AND after that sort on date?
This is the answer to my question: $args = array( ‘post_type’ => ‘myType’, ‘post_per_page’ => $number, ‘showposts’ => $number, ‘meta_query’ => array( array( ‘key’ => ‘month’, ‘value’ => array(date(“F”),date(“F”, strtotime(‘+1 month’))), ‘compare’ => ‘IN’ ), array( ‘key’ => ‘day’, ‘value’ => date(“j”), ‘compare’ => ‘>=’ ), array( ‘key’ => ‘year’, ‘value’ => date(“Y”), ‘compare’ => … Read more
Found the issue to be the types_render_field() function (I am using the Toolset plugin). Switched to using get_post_meta() instead and it works fine.