add custom javascript into head of only one page with plugin or custom field (2 posts)

  1. ashtonbrn
    Posted 4 years ago #

    I have one page that needs some JavaScript added to the <head> tag. I don't want it on all the pages, just this one.

    I'm not good with php or modifying the theme too much.

    I was hoping to find a reliable light weight plugin.
    I'd be open to maybe use a the custom field if that was easy to setup as well, but am not familiar with php or WordPress theme code.

    Is there simple way to add custom html inside of the <head> tag on a page by page basis?

  2. phpadam
    Posted 3 years ago #

    You could add this into the header.php file. The example uses the home page. Just replace 'home' with whatever page you want to add the code to.

    <?php if (is_page('home') ) { ?>
    <!--home page custom JS-->
        <script type='text/javascript' src="<?php bloginfo('template_directory'); ?>/Scripts/customJS.js"></script>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic