WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. Landing Page 1 - landing-page-template-one.php will need very different style and js than the blog or homepage.

share|improve this question

You can use the is_page( 'landing-page-template-one' ) conditional around your page specific styles / scripts as part of your over-all enqueue statements.

function my_enqueue_stuff() {
  if ( is_page( 'landing-page-template-one' ) ) {
    /** Call landing-page-template-one enqueue */
  } else {
    /** Call regular enqueue */
add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );

You could even chain more elseif into the above for other pages, etc.

Reference: Functions Reference - is_page()

share|improve this answer
worked. Awesome. Thanks Edward. – Sean Aug 8 '12 at 19:45
You're welcome Sean, glad to help. – Edward Caissie Aug 15 '12 at 19:27
I think using is_page_template() is preferable since the page slug is easily changed. This solution, while it works fine, would break if the slug was changed. See kchjr's solution if anyone runs into problems in the future. – BODA82 Nov 14 '15 at 22:46
Thank you! For others who stumbled upon this: the conditional statement is_page must be in the function attached to the action and not wrapping the add_action statement itself. If you do wrap the add_action statement in a conditional, it will be to early in the processing of the page to know what page it is. – Hendeca May 25 at 3:32

If you plan to do a lot of WP development you should bookmark this page: http://codex.wordpress.org/Conditional_Tags

The other answer works but the conditional relies upon your page slug (myurl.com/this-is-the-slug) never changing. A more reliable method (IMO), and one that fits this case, would be to use the is_page_template('example-template.php') conditional check instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.