Exclude authors IDs from WP_Query

exclude specific authors from WP_Query You can do it like so: $args = array( ‘author__not_in’ => array( 10, 3, 4 ), ); $posts_query = new WP_Query( $args ); But if you meant “from WP_User_Query“, then in WP_User_Query, you should use the exclude parameter, and that array(‘who’ => ‘authors’) shouldn’t be in meta_query: $args = array( … Read more

add_filter to specific WooCommerce Category

To account for variations, I’d suggest using $product->get_category_ids() and checking if your category is in there: function wcs_custom_get_availability( $availability, $_product ) { $workshops_category = get_term_by( ‘slug’, ‘workshops’, ‘product_cat’ ); $product_category_ids = $_product->get_category_ids(); if ( ! in_array( $workshops_category->term_id, $product_category_ids ) ) { return $availability; } // Change In Stock Text if ( $_product->is_in_stock() ) { $availability[‘availability’] … Read more

How to append classname to body tag if guest user

Yes, there’s the body_class filter. You could use e.g. function body_class_guest_user( $classes, $class ) { if ( ! is_user_logged_in() ) { $classes[] = ‘guest-user’; } return $classes; } add_filter( ‘body_class’, ‘body_class_guest_user’, 10, 2 ); However you could equally well just use the :not() selector, e.g. body:not(.logged-in) (browser support), or absence of logged-in i.e. set up … Read more