0

I'm using _s to build a theme. I want to have different styles for different pages. I can figure out how to get two pages working but I want different styles for 5 pages? Maybe an else if statement? I would really appreciate some help.

here is my code.

 if (is_page_template('page-templates/page-about.php')) {
        wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/about.css');
    } else{
        wp_enqueue_style('sentiencesentient-layout-style' , get_template_directory_uri() . '/layouts/content-full.css');

        }

many thanks

0

You can use elseif to check another page template and you can go on like this.

if ( is_page_template('page-templates/page-1.php') ) {

    wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/style1.css');

} elseif ( is_page_template('page-templates/page-2.php') ) {

    wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/style2.css');

} elseif ( is_page_template('page-templates/page-3.php') ) {

    wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/style3.css');

} elseif ( is_page_template('page-templates/page-4.php') ) {

    wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/style4.css');

} else {

    wp_enqueue_style( 'sentiencesentient-layout-style' ,    get_template_directory_uri() . '/layouts/style5.css');
}
  • Works a treat. Thankyou for your fast reply. Have a nice day! – Rico Shaft Sep 5 '14 at 11:38
  • Cool :) have a nice weekend – Robert hue Sep 5 '14 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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