Enqueue Stylesheet or Javascript on just one Wordpress Page or Post

To enqueue a css stylesheet or external javascript file on just one page use the following function with a conditional if statement in your child theme functions.php script.

function register_online_form_style() {
  if ( is_page( '104' ) ) {
    wp_enqueue_style( 'contactForm', get_stylesheet_directory_uri() . '/site/css/form.min.css' );
  }
}
add_action( 'wp_enqueue_scripts', 'register_online_form_style' );

104 is the page or post's ID
contactForm is the name of the script

Pretty starightforward

Comments

Popular posts from this blog

How to Display Custom Wordpress Header with Google Analytics Site Tage and Adwords Site Tag

Complete Uninstall iTunes on Windows 7 Pro 64-Bit