How to exclude a taxonomy from shop & search page wooCommerce?

This might help you with Shop page listing: https://docs.woocommerce.com/document/exclude-a-category-from-the-shop-page/ And for Search page, here is a snippet that might help: function exclude_services_category_products_from_search( $query ) { if ( is_search() && !is_admin() ) { $array_with_service_category_id = []; $tax_query = $query->get( ‘tax_query’ ) ?: []; $tax_query[] = [ ‘taxonomy’ => ‘product_cat’, ‘terms’ => $array_with_service_category_id, ‘field’ => ‘term_id’, ‘operator’ … Read more

Update variable value via add_filter

Filters only allow you to directly modify the first value passed to them. In your case, that’s null. If you shifted view_slug up a place, it would be available to filters using your events_view_html tag. add_filter( ‘events_view_html’, ‘my_callback’, 10, 3); // passing 3 args to the callback, assuming you need them for something. function my_callback( … Read more

filter hook to load a different post/page on current post/page

You can use the request hook to change the loaded page for the same URL: add_filter( ‘request’, function( $request ){ //Replace this with custom logic to determine if the user should see the contact-team page $load_team_contact = true; if( $load_team_contact && isset( $request[‘pagename’] ) && ‘contact’ == $request[‘pagename’] ){ $request[‘pagename’] = ‘contact-team’; } return $request; … Read more

Add a counter beside menu item label

You can wp_nav_menu_objects filter hook and you can compare your menu label with the condition and append your cart count. check below code. code will go active theme functions.php file. tested and works. function modify_cart_label_in_nav_menu_objects( $items, $args ) { if($args->theme_location == ‘primary’){ foreach ( $items as $key => $item ) { if ( $item->title == … Read more

How to change footer credit text in Twenty Twenty One theme with a hook?

That snippet contains no hooks, so there isn’t anything for you to hook onto. If instead the file had something like: <div class=”powered-by”> <?php echo apply_filters( ‘credit-text’, ‘Powered by <a href=”https://wordpress.org/”>WordPress</a>’ ); ?> </div> Then you could do something like: add_filter( ‘credit-text’, ‘wpse385946_credit_text’ ); function wpse385946_credit_text( $credit ) { return ‘Site by <a href=”/”>Me!</a>’; } … Read more