jQuery Plugin Activation Code Added in the Template File (WordPress Theme, ThemeForest)

I am developing a one page personal portfolio WordPress theme.

In the home/main page there are several sections. In portfolio section there is a filtering plugin activated.

The problem is when I go to the other pages like single post page, archive page, search page etc., a JavaScript error occurs for that filtering plugin where there are no filtering plugins activated.

At first, I have enqueued that plugin only for the main/home page. Now the previous error has been removed, but another new error occurs for the plugin activation code (which is in the main.js file) of the same plugin.

At this stage I have made an experiment. That is I have removed the activation code form the main.js file and added that in the specific section(i.e., portfolio section) of the template file( main page/ home page). And now everything goes well.

The activation code here:

<script>
jQuery(document).ready(function(){
jQuery('.portfolio_items').filterizr();
jQuery('.simplefilter li').on('click', function() {
jQuery('.simplefilter li').removeClass('active');
jQuery(this).addClass('active');
});
});
</script>

Applying the same process I have made owl carousel activation data dynamic (redux framework).
And this code is in the service section area.
Here is the code snippet:

<script>
jQuery(document).ready(function(){
    jQuery('#service_owl_carousel').owlCarousel({
            autoplay: true,
            dots: false,
            responsive:{
            0:{
                items:1,
                nav:true
            },
            767:{
                items:2,
                nav:true
            },
            991:{
                items:<?php echo $b_service_content_layout; ?>,
                nav:true
            }
        }
        });
}); 
</script>


And now my query is:
  1. Does ThemeForest allow me to use jQuery plugin activation code in the process mentioned above i.e., adding jQuery plugin activation code in the specific section and make dynamic using Redux Framework ?

Thanks for your time. 🙂

Read more here: jQuery Plugin Activation Code Added in the Template File (WordPress Theme, ThemeForest)

Leave a Reply

Your email address will not be published. Required fields are marked *