Merge 2 args in one WP_Query and order it by date

I’m trying to merge 2 WP_Query in a new WP_Query and then order all posts in this new merged query by date descending. I can merge 2 WP_Query and work fine, but I can’t order the new query $args1 = array( ‘posts_per_page’ => ’10’, ‘post_status’ => ‘publish’, ‘post_type’ => array(‘news’,’partners’), ‘orderby’ => ‘date’, ‘order’ => … Read more

Order get_users() by last login date. Is it possible?

I want to create a page that displays all the blog users ordered by the last login date. I’ve tried with the get_users() function and I can succesfully get the users’ list, but not in the order I want: $query = get_users(‘&offset=”.$offset.”&orderby=login&order=DESC&number=”.$number); I think that the orderby=login is not what I”m looking for… Is there … Read more

Order Posts by meta value AND published date

I want to order WP posts by meta key named “sort_date” and if it doesn’t exist it should use the post’s published date to order posts. Below is the code i am currently using function pre_get_posts_custom($wp_query) { if ( !is_admin() && $wp_query->is_main_query() && !is_page() ) { $meta_key = ‘sort_date’; $wp_query->set( ‘post_type’, array( ‘post’, ‘article’ ) … Read more

wp_enqueue_script order – external vs inline js

I have a few scripts loading with my theme: // loading script.js <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/27397/script.js”></script> // doing something using script.js <script type=”text/javascript”> script-var: <?php echo get_option(‘script1-var’);?> </script> They work well, but when I do wp_enqueue_script instead of <script src=””> the script is loading AFTER in-line js content, so: // enqueuing script.js wp_enqueue_script(‘script-js’, get_template_directory_uri() .”/scripts/script.js”); // … Read more

How to query different post types in specific order?

I have 3 posts types, articles, news and tips. On the home page I want to query 20 posts in this order: article, article, news, news, tip, …// same order again until 20 If I use a custom query like so: $query = new WP_Query(array( ‘post_type’ => array(‘articles’, ‘news’, ‘tips’), ‘posts_per_page’ => 20, )); I … Read more