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()
- What is the best php version to use with WordPress?
- How to call a function only once (global variable scope)
- Multiple is_page() in page.php
- Get author full name
- Where should I install a PHP library into WordPress so that code in a webpage can activate it?
- Does the debug.log do log rotation?
- How to make WordPress plugin check for database changes and then do something?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- wp_get_attachment_url filter won’t accept two arguments
- Translating add to cart woocommerce button [closed]
- nowplaying.include.php Will Not Display Results
- Am I not understanding plugins?
- Passing the page ID to a login php script
- SetCookie simply not working
- wrong php date()?
- Looking for most performant way to execute several similar WP queries within shortcodes
- It is a good idea to store values from the global $post if they are used multiple times?
- Vagrantpress + composer
- esc_url returns incorrect URL
- Customize Time Stamp
- Combine two filters into a single call
- How to output widget
- Recent posts with featured image or fallback image with permalink
- CSS from textarea in options page to frontend what to do
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Display menu point only if there are published posts in that category
- What query string parameter is available for index.php, that works for both pages and blog articles?
- Sending data from custom inputs in WordPress comment form in the admin notification email
- export a csv file from the database with a cronjob
- How to set a min number of words for a blog post
- How to sanitize any integer input field in wordpress?
- Query Pages and post excerpts dynamically
- Get my site session in wordpress?
- Register a menu – Error Header
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- Update postmeta after theme switch
- Set site title & tagline with wp.config or function.php
- Shortcode to embed Edit Account form not working
- Include style.css in the Child Theme with PHP
- Get user custom field value on function.php
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Add New Text Box To WordPress Twenty Seventeen Header
- WordPress homepage setup not working on first load
- Get the id of all images in a post
- Dynamically display font icons in widget
- Setting a default thumbnail url if no thumbnail
- Dynamically Generate Functions and Hooks
- PHP if have image display image, if else text
- Covert WordPress Blogname into JQuery
- displaying a fall back query if there’s nothing in the post-type category
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- How to list users like an archive page 10 users on page and have navigations
- how to add datas in taxonomy to post with wp_insert_post
- Add custom fields from different posts
- Need help for some PHP code
- How do you get the current post taxonomy so I can get the current post taxonomy? into a variable to THEN loop through all post with that taxonomy.,
- Remove an action created by a Gravity Forms add-on
- Displaying the Archive Page’s Name on the Page
- Adding HTML Code to Replace Text in PHP
- Get nice name of category from slug (remove dashes of category)
- How to disable PHP functions in WordPress?
- PHP “warning include_once(): Failed to open stream” Simple HTML DOM in WordPress Child Theme
- Posts missing on author page
- How do I add a predefined class to a custom html element?
- How do I make the following articles collapse within the month?
- How to access this jQuery/AJAX data in a PHP file/WordPress plugin
- Taxonomy Child Term, Counter is staying on 0
- LinkedIn Share Post Button
- Inserting other fields to existing registration form in a WordPress theme
- wordpress more than one ajax request at the same time issue
- PHP drop down menu for my get_category child of
- How to display recently modified posts on recent post widget in wordpress
- Explode Content within specific HTML element
- add_rewrite_rule questions
- PHP Shortcode – 500 error
- Non-array argument in array_merge()-function [closed]
- Add specific content after specific text in every post
- retrieve wordpress post-meta using php not wordpress functions
- Too few arguments for printf() [closed]
- custom data in url
- Dynamically append custom post type to end of url
- Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]
- Pagination in category.php not functioning
- How to handle parent and child pages?
- Wrapping the_content() in Schema articleBody tag? [closed]
- Custom Filtering date with newsletter
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted