Written by me@grafxflow
01 Sep, 2012
2
2,021
Normally if you wanted to include a custom javascript or css in your WordPress theme, you would edit the header.php in the WordPress admin.
Appearance/Editor and choose Header (header.php)
But lets say you only wanted it to be included on a specific page, well again edit the header.php file and you need to add the following based on the page being called 'video'.
For javascript:
<?php if (is_page('video') ) { ?>
<!-- Embed custom javascript -->
<script type='text/javascript' src="<?php bloginfo('template_directory'); ?>/js/javascript_custom.js"></script>
<?php } ?>
For CSS:
<?php if (is_page('video') ) { ?>
<!-- Embed custom CSS -->
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/css_custom.css" media="screen" />
<?php } ?>
A quick note... you can also use the post/pages id number if (is_page('12').
24 Nov, 2013
25 Mar, 2010
22 Nov, 2009
I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!
Follow11 Jul, 2023
21 Jun, 2023
Views: 165,964
Views: 40,147
Views: 36,851
Views: 33,460
2 Response
Finch
07 Dec 2013
You saved my life man!! Thanks a lot!!
me@grafxflow
07 Dec 2013
Glad to help.