Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
Ok here’s my altered function but this one doesn’t work at all but maybe you can see wher i go wrong function insertUserShoppingMetaData($params) { global $wpdb; $shopping_meta_table=”wp_shopping_metavalues”; $wp_user_id = $params[‘wp_user_id’]; $checkKeyValues = $wpdb->get_results(“SELECT meta_shopping_key FROM $shopping_meta_table WHERE wp_user_id = ‘$wp_user_id'”); //print_r($checkKeyValues); foreach ($params as $key => $val) { foreach($checkKeyValues as $check){ //UPDATE OR INSERT if … Read more
Meta query must be done with a nested array. So it may look more like this: $query = new WP_Query( array( ‘meta_query’ => array( array( ‘key’ => ‘duedate’, ‘value’=> $today, ‘compare’ => ‘>=’, ), ), ‘paged’ => $paged, ‘posts_per_page’=>’20’ ) );
Why are you using $wpdb to query from database. Use WP_Query or get_posts instead. This is how you can query from WordPress database and get 4 latest posts from category id 24. <?php $args = array( ‘post_type’ => ‘post’, ‘cat’ => 24, ‘posts_per_page’ => 4, ‘ignore_sticky_posts’ => 1 ); $my_query = new WP_Query( $args ); … Read more
Ordering posts alphabetically by meta keys and title
Just add this before your code $authors = array( 1, 2, 3 ); // privileged users array $signed_in_user = wp_get_current_user(); // get current user // check if singed in user is in authors array if ( in_array( $signed_in_user->ID, $authors ) ) : And then this after your code <?php else : ?> This message will … Read more
Some thoughts on how I would approach this. I can update later with some code if necessary when I have the time. I would handle the first page with two additional queries, so three loops on page one. Hook pre_get_posts and do two meta queries for the three posts that will appear in the first … Read more
There is no native function which to accomplish what you need. The only possible solution that I can think of is to make use of usort to sort the returned array of posts from your custom query You will need to do the following: Set you list with the desired tags Get a list of … Read more
It sounds like what you really might want is a transient. WP Transients are a way to cache the results of a query, and set an expiration date on that cache. So you could cache the results of your example from above for 24 hours. If anyone requests that data while the cache is still … Read more
What do you mean by “dynamic” ? Do you want it to work with different posts? If so, that’s simple. Before your get_posts query function, get page terms, and pass them to your array. You can get taxonomies with <?php get_the_terms( $yourpostid, ‘your_custom_taxonomy’); ?>