Skip to content

Instantly share code, notes, and snippets.

View wordpress-hide-admin-menu-bar.php
<?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 Oct 3, 2020
[Wordpress] Exclude product category by slug in seach result.
View wordpress-exclude-product-categories-in-search.php
<?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',