Different CSS Styles for a subset of pages

Is it possible to create a style sheet separate from your main/child style sheet and point a set of pages to that secondary style sheet? For example, I have a theme and style for my 75% of my site that I am happy with. But I have want to carve out part of the same site and have it looked differently -- same layout but different color scheme. I could edit the page styles for each page but I don't want to update 20 pages with the custom style. Is there a simpler way in Wordpress to simply point those 20 pages to another stylesheet?

  • Luís

    Hi @Randy,

    I hope had been good today!

    You are referring Upfront themes or other theme?

    If you are referring to other template, my first thoughts are (maybe not the best options):

    1) Create a new page template and import other stylesheet.

    https://premium.wpmudev.org/blog/creating-custom-page-templates-in-wordpress/

    2) Add a function in your theme functions.php to enqueue other stylesheet in specific pages.

    2.1) You need to create another stylesheet (@import the general CSS in this new stylesheet and override only the styles you want) and upload to the root folder of your theme.

    2.2) Using the example of Twenty Sixteen theme:

    function add_new_stylesheet() {
    if (is_page( array( 'about', 'contact', 'contact' ))) {
    	//dequeue existing stylesheets//
    	wp_dequeue_style( 'twentysixteen-style' );
    	//enqueue new stylesheet
    	wp_enqueue_style( 'style2', get_stylesheet_directory_uri().'/style2.css' );
    }
    }
    add_action( 'wp_enqueue_scripts', 'add_new_stylesheet' );

    I hope this information has been helpful. If I can help you in this or other questions, please let me know!

    Cheers, Luís

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.