Skip to main content

How to add custom CSS code / JS script to WordPress website (Without Plugin)


 If you want to add script to your website with custom code and don't want to add any plugin or want to add the new functionality to theme or plugin, you just need to add below script in functions.php file.


ADD CSS / SCRIPT TO  HEADER

add_action( 'wp_head', 'add_custom_script_to_head' );
function add_custom_script_to_head() { ?>
    <style>
        // Your your css code here
    </style>

    <script type="text/javascript">
        // Your js scripts here
    </script>
<?php  }


ADD CSS / JS SCRIPT TO WP FOOTER

add_action( 'wp_footer', 'add_custom_script_to_footer' );
function add_custom_script_to_footer() { ?>
    <style>
        // Your your css code here
    </style>    

    <script type="text/javascript">
        // Your scripts here
    </script>

<?php }

Comments

Related Posts

How to Create Your Own WordPress Shortcodes (Without and With Attribute)

How To Add Custom Scripts (Css/Js/HTML) To WordPress Header And Footer (With Plugin)