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()
- How can I send an email using PHP?
- How to fix the admin menu margin-top bug in WordPress 5.5?
- Should I use spl_autoload_register() in my plugin?
- How do I make an HTML table from a database table?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- How build a custom login/register form with error handling?
- Shortcode putting html such as
- Load post content into iframe
- Editor role cannot save custom theme options
- Does WordPress cache get_user_meta() results?
- wp_customize_image_control default value
- Initialize WordPress environment to use in a real cron script
- Installing wp3.2.1 on IIS; getting empty sessions
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- WordPress widget in custom theme
- “wp_enqueue_style();” don’t load new edited style
- Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes)?
- external wordpress pages using wp-blog-header
- Specific Loop For 2 Within Each
- POSTS list in WordPress by views
- Why WordPress uses 4 tables to manage terms
- How do I enable HTML5 prefetching on this page?
- Using FirePHP with WordPress
- Anything I can add to functions.php to make text widgets accept PHP?
- What’s the proper way to use wp_enqueue_script/style?
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Append a term to WooCommerce product existing product category terms
- user_id error: Only variables should be passed by reference
- How to find the output of contact form 7 shortcode? [closed]
- Print number of post (in reverse)
- After upgrading to PHP 7.0 my contact form outputs error
- Count number of published posts by type
- Does wp-cron runs all tasks scheduled at same time together or one after other?
- WordPress blockquote removes “ tag
- Is it necessary to upgrade to php7? [closed]
- Can’t increase posts_per_page by variable
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- Can A Shortcode Get HTML/Text From Content And Return It Twice With Added HTML?
- Why is ‘admin’ missing from my admin links?
- List of posts by day of the week
- If Meta Checkbox is checked, do something?
- Output 2 items within the Loop
- Why does running get_the_excerpt() when generating JSON file take 28 seconds vs. 599 milliseconds without it?
- How to check If Oembed is empty or not
- How do I access the media settings
- Will simple function names in a class structure conflict with other plugins?
- How can I add pagination and how can I change thumbnail size?
- How can I output a php value into a JS file within WordPress?
- Set post title based on first h2 element in the content section
- Custom field value not saving when it contains a URL?
- Do changes to WordPress permalink custom structure affect old urls?
- Creating bulk posts with Youtube videos
- APC 500 Internal server error [closed]
- Call External Object in Class Function During Callback
- WordPress to end support for PHP 4?
- Why does WordPress remove my variables in the URL?
- How do I let users upload files to a chosen location?
- Adding hreflang tags automatically in WordPress subdirectory multisite
- How can i upload images in an admin page?
- get current custom post ID by WP_Query method
- add_image_size for header_image
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Performance impact of rewriting WordPress URLs
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Wp-login appears White Screen, Error: Cannot modify header information
- WordPress: Access a plugin from within a theme
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Mute Debug Messages from Plugins
- Reprinting tags with all attributes
- Set WP_query ‘order’ option by another tables value
- Creating user status mode in WordPress
- Need Help Fixing My Iframes [closed]
- Implementing update_user_meta
- wp_ob_end_flush_all and wp_suspend_cache_addition()
- edit_comment_link is not showing for comment author
- Css loads very slow [closed]
- Why is image hard cropping for one image using add_image_size not working?
- database sent to a JSON file
- Settings API callback function inserts html quotes from nowhere
- Show when user is online/offline in real time on user_profile.php
- Enable custom logo upload if logo is not in header
- wordpress archive a user
- How do I get around “Sorry, this file type is not permitted for security reasons”?
- theme_root returning a truncated URI