Order posts by more than one variable (meta_key and publish date AND time)

I found this link about “a more powerful ORDER BY in WordPress 4.0” and it led me to try this code: <?php $query = new WP_Query( array( ‘post_type’ => ‘result’, ‘posts_per_page’ => 100, //’paged’ => $paged, ‘meta_key’ => ‘event_date_results’, ‘orderby’ => array( ‘meta_value_num’ => ‘DESC’, ‘post_date’ => ‘DESC’), //’order’ => ‘DESC’, ‘meta_value’ => date(‘Ymd’), ‘meta_compare’ … Read more

Using the same WP_Query for shop and widgets in WooCommerce shop

The reasons your pre_get_posts filter does not work on the widget are the condition !$wp_query->is_main_query() makes the filter handle only the main query and nothing else Your special parameter myattr is “self populating” only on the main query but it is not propagating automatically to other queries. To make it work on the widget, the … Read more

WP_Query causing links to not work

I’m sorry. I didn’t create a single.php file. In my learnings I have discovered that if no single.php file exist then WordPress falls back to index.php. So the link were actually working but just using the same template. Again im sorry for wasting your time.

WP_Query – show posts where meta value and user_email match

Both examples of your code throw errors on the while line: <?php while ( $users_query->have_posts(): $users_query->the_post() ) ?> The while will work if you move the parenthesis from the end to before the colon, and replace the parenthesis with a semicolon. <?php while ( $users_query->have_posts() ) : $users_query->the_post() ; ?> (The Errors turn up fast … Read more