WP_Delete_user link creation

WordPress does not provide delete user link as it provides for deleting posts. Therefore, we should do this using Ajax. Following would be the approach towards solving this issue: Add user id as attribute to a tag When anchor is clicked, get the user id and fire ajax request which would delete the user. Kindly, … Read more

wp_query args adding muitiple tax_querys

You could use IF conditions to add the parameters, $args = array( ‘post_type’ => get_post_type(), ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, ‘no_found_rows’ => true, ‘tax_query’ => array(), ); if(condition){ $args[‘tax_query’] = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘product_category’, ‘field’ => ‘slug’, ‘terms’ => array($category->slug), //Supply the current product_category terms ), array( … Read more

Add posts to WP Query object

You can modify the query using the pre_get_posts hook, you will have to add the parameters of your query to the query provided by WordPress inside you callback function (exclude_category in the example below): Example from the WordPress Codex: function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-1,-1347’ ); … Read more

Filter and Order by Multiple Custom Meta Values

For multiple meta value you have to use “IN” $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘shows’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘start_date’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘show_location’, ‘value’ => array(‘second’,’third’), ‘compare’ => ‘IN’ ) ) ); // get results $the_query = new WP_Query( $args ); The IN comparison … Read more