It’s better to use PHP to remove things when possible, because if you just use JS, they’re still technically there on the page. What if a visitor is on a slow-loading network and the JS doesn’t kick in for a long time, so they see the filters long enough to use them? If you can find out what actual template file is being used to display the page when there are no products found, you can probably make the changes there and just make them conditional – only show the filters if woocommerce_no_products_found
is false.
Aside from that, the problem you’re running into is that you are adding your myhelp
action to the woocommerce_no_products_found
hook. That means your function will only run when that hook fires – and it doesn’t fire when wp_head
fires, it’s much later. That’s why your code isn’t injecting itself into the head.
Related Posts:
- Change dns-prefetch to preconnect with correct protocol
- Header has extra HTML block at top before my code
- storing wp_head in a variable?
- action hook wp_head higher priority as all other plugins/hooks
- Remove meta description on certain pages
- wp_head function not outputting
- How to style injected code in header section?
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Add a top bar to a wordpress theme without editing the header.php file?
- Load admin bar without wp_head or wp_footer [duplicate]
- How can a ‘scripts’ directory be hooked into wp_head();?
- Particular meta tag – viewport – insertion when dealing with plugin
- How to modify default tags in wp_head()
- Execute a PHP Function when a Block is used and access it’s attributes
- Using Argument from Function to Re-Direct Visitor (WordPress)
- Use $wpdb or other PHP script method to find/replace in WP database
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- preg_replace regex problem
- Compare $_POST returned values with term array
- Remove item in Checkout
- email alert for product availability
- How to Update post_modified of all wordpress post
- How to Change CSS Colors from Custom Plugin Settings Page
- malware undetectable by multiple scans
- how to serialize() mysql update data
- Simple WordPress endpoint route doesn’t work
- Correct PHP to output a single result of a Function with SQL Query
- How to relocate paypal button gateway on checkout page in woocommerce
- How to create a field in customize and show that in header.php?
- WordPress shortcode returns the data before
- Passing the name of selected color from the custom component to `render_callback`
- I am receiving a pluggable.php warning sign on my only http:// page
- How to remove the h6 tag for the entry-category Class
- your php installation be missing the MySQL extension WordPress CPANEL [closed]
- Can’t add script immediately after the opening tag on login page?
- Find Site ID From WP_Post
- Is it possible to create new user from external form using REST API?
- WP_Query: getting posts where custom field exists
- Foreach loop inside an array_merge
- page-slug.php not working but only for specific slug
- {$key} or $key?
- How to show meta value code HTML after x paragraph
- Redirect to a page for only logged in user
- Send a mail to specific address in a custom field when a new comment is made on a specific post
- Display the 3 latest WordPress Posts on a Static Page Outside WordPress
- Export Form Data to a CSV then send it as an attachment – contact form 7
- Override user-edit.php to design own profile page
- Live to Local on MAMP, not working, outputting functions.php code
- Remove extract from function
- Undefined offset: 3 in custom function
- List all blogs, but exclude the main site
- How to append to an array and return the results in a filter?
- How to specify the path for require_once in a child theme?
- Set site title & tagline with wp.config or function.php
- How can I add a new row in a separate database when someone registers via WordPress?
- Shortcode to embed Edit Account form not working
- Redirecting to a custom forgot password page
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- Warning: printf(): Too few arguments in helpers.php file
- $_SESSION variable not saving on page refresh or new page
- Form search query – displaying ACF “Post Object” field as results
- Errors after upgrading PHP to 7.4 WordPress
- Design with Elementor and code the rest?
- Add additional functions file instead of functions.php
- How to make jquery count down timer function manually editable
- Issue with fetching mysql data and displaying results via shortcode in webpage
- wp_insert_post() with HTML tags using PHP
- How to rename woocommerce-billing-fields
- Any ideas why I am getting “I’m getting “wp-admin/admin-ajax.php 401 (Unauthorized)”
- InnerBlocks with allowedBlocks not working with acf_register_block
- Can a plugin redirect product page based on IF condition?
- Cant register rest routs from class instance
- Hierarchical taxonomy list with modificated term links
- How can i change variable if condition is not met
- Shortcode not staying inside div tag
- if isset not working for undefined index, how to fix
- HTML showing after PHP code in tag
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- Decoded malware code [closed]
- Double Curly Brackets in Php
- Line breaks inside shortcode variable
- How to return site_url() without https://
- WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin
- How set a custom URL for a new theme file in WP?
- PHP-warning in post-template.php and no loading content on pages
- How to unlink all posts from tracking same amount of views
- Connecting to another server database from the wordpress plugin
- Site Health says I’m running an older version of PHP even after I upgraded to 7.4.4
- Login redirect. Check user meta and redirect accordingly
- PHP Notice: Undefined offset: -1 – Navigation Previous/Next
- WordPress REST API register_rest_route give a 500 error
- How to use wordpress function wp_enqueue_script() in php?
- Where to insert redirect code based on http_referer?
- Add class to website based on post taxonomy
- Form Submission Not Working In Custom Theme
- Need php code’s output to display underneath a Divi Module
- Where is the PHP code generating an element?
- How do I check or test a WordPress Auto Year Change Script?
- Parse error: syntax error, unexpected ‘,’