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

How To Get Some Data From WordPress Database Using WordPress $wpdb Query?

I am trying to get some data from WordPress database tables in a plugin. For that, I am using the below code… global $wpdb; $findID = $wpdb->get_var(“SELECT ID FROM wp_posts WHERE post_name=”hello-world””); echo $findID; But it not giving me the post ID in echo? Is there anything wrong…??? 2 Answers 2 Just to clarify the … Read more

How to check if a post “does not have term” in conditional statement?

We know that we can check if the particular post has a term by using this code: has_term(‘term’, ‘taxonomy’, $post->ID )) { I was wondering if there is a code to check if a particular post does not have a particular term. Thanks. 2 Answers 2 if ( !has_term(‘term’, ‘taxonomy’, $post->ID )) { Use the … Read more

Get random terms

Is it possible to get random terms? To get random posts you could use WP_Query and set ‘orderby’ => ‘rand’. But is there any way to do that with terms? I’ve tried this: $terms = get_terms( array( ‘taxonomy’ => ‘webshops’, ‘hide_empty’ => false, ‘orderby’ => ‘rand’, ‘number’ => 6 ) ); 1 Answer 1 Unlike … Read more

Get List of all the Authors

How could i get List of all the Authors? author.php file shows the Information about Individual Author. for example: http://domain.com/author/bj that returns the Bj’s Profile. if i enter http://domain.com/author it returns 404 Not Found Author page shows author’s avatar, Author’s Name and description. how can i list out all the authors? Need Help! 3 Answers … Read more

How to select posts from one category but exclude posts in another category?

I am trying to select posts that have category id 4 but exclude posts that also have category id 2 Here’s what i’m trying $query = new WP_Query(array( “cat__in” => array(4), “cat__not_in” => array(2), “post_type” => “post”, “post_status” => “publish”, “orderby” => “date”, “order” => “DESC”, “posts_per_page” => $limit, “offset” => 0 )); However, it’s … Read more