Categories

Saturday, December 21, 2024
#919814419350 therichposts@gmail.com
WoocommerceWordpressWordpress HooksWp Tricks

How to add script only for woocommerce shop page with wordpress hook?

How to add script only for woocommerce shop page with wordpress hook?

Hello friends, welcome back to my blog. Today in this blog post, I am going to tell you, How to add script only for woocommerce shop page with wordpress hook?

WordPress Hooks Add Script on Woocommerce Pages

For WordPress lovers must check the below links:


Friends here is the working code snippet for How to add script only for woocommerce shop page with wordpress hook? and please use this carefully to avoid the mistakes:

1. Firstly guys we need to add below code into our WordPress activated theme’s functions.php file:

add_action('wp_footer','custom_jquery_shop_script');

function custom_jquery_shop_script(){

    if ( is_shop() ): 
        ?>
            <script type="text/javascript">
                // Ready state
                (function($){ 
                    alert("shop page")
                })(jQuery); // "jQuery" Working with WP (added the $ alias as argument)
            </script>
        <?php
  endif;
  
}

 

Now we are done friends. If you have any kind of query or suggestion or any requirement then feel free to comment below. There are lots of WordPress hooks and filters  and I will share into my future posts and we should use them rather then do custom code in theme core files or in plugins files.

Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding must watch video above.
I will appreciate that if you will tell your views for this post. Nothing matters if your views will good or bad.

Jassa

Thanks

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.