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 have one stylesheet linked to my Wordpress page in header section:

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" />

Now, I want to load different stylesheets on a few pages or sub-pages.

What's the best/correct way of achieving this?

I'm thinking about writing my own shortcode calling "wp_enqueue_style", is that a good idea?

share|improve this question
up vote 1 down vote accepted

Don't use a shortcode for wp_enqueue_style(); it won't do any good, because by the time the shortcode is parsed, all the relevant hooks ( wp_head, wp_print_styles) will have already fired.

Write a function, in functions.php, to enqueue different style sheets based on is_page( $id ) (where $id can be an ID, slug, or title). Then hook that function into wp_enqueue_scripts.

p.s. note also: you should be using get_stylesheet_uri() in your default stylesheet link, e.g.:

<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>/style.css" />
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.