Skip to content

Instantly share code, notes, and snippets.

<?php
/**Remove Admin Bar Button**/
add_action( 'admin_bar_menu', 'me_remove_admin_bar', 999 );
function me_remove_admin_bar( $wp_admin_bar ) {
if( is_user_logged_in() ) {
$user = wp_get_current_user();
$roles = ( array ) $user->roles;
if (in_array('editor',$roles)) {
//to check what nodes
@jennlee20
jennlee20 / wordpress-exclude-product-categories-in-search.php
Created October 3, 2020 04:55
[Wordpress] Exclude product category by slug in seach result.
<?php
function jenn_search_filter_pre_get_posts( $query ) {
if ($query->is_search()) {
$query->set( 'post_type', array( 'product' ) );
$tax_query = array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'your-product-category-slug-1',