WordPress.org

Ready to get started?Download WordPress

Forums

Stylesheet only for single pages (5 posts)

  1. Micbow
    Member
    Posted 1 year ago #

    Hi I was wondering how to get single pages to only to use an alternative stylesheet I've created?

    I've created a new header just for the single pages, header-single.php, and designated the new stylesheet there but it still accesses the main stylesheet. How do I stop it from doing that?

    Thanks

  2. JungleSpace.net
    Member
    Posted 1 year ago #

    You would need arrange the css file such that it loads after the main css. In other words put the line

    <link ...>

    after the main css line.

    Use can use logical statement to only load CSS on specific pages using functions like is_page(), is_single().

    http://codex.wordpress.org/Function_Reference/is_page

  3. Micbow
    Member
    Posted 1 year ago #

    Hi, Thanks for the answer.

    I don't want to load the main css on the single pages at all as it has different values for the body{} css and contains all the css that is required for the single pages.

    You see I want to make the single pages mobile friendly so having one stripped down stylesheet that is the only stylesheet that is loaded is what I am trying the achieve.

    Therefore it looks as if adding functions to include or exclude stylesheets is what's required?

    How would you write the function to do this?

    Thank You

  4. JungleSpace.net
    Member
    Posted 1 year ago #

    if( is_single() ){
    //call stylesheet
    }else{
    //call main stylesheet
    }

  5. Micbow
    Member
    Posted 1 year ago #

    Thank for that. I'll give it a go.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags