changing stylesheet for single posts in specific category (6 posts)

  1. funkyvega
    Posted 8 years ago #

    I've been searchign for week on the forum and still can't figure it out.

    i've been working on a gallery page for my friend. I was able to customize the CATEGORY PAGE by creating a category-7.php file. Thats not the problem, see here: http://www.sayuncleinc.com/?cat=7

    However, i want to change the way the individual post looks when the post is in category 7. For example: http://www.sayuncleinc.com/?p=30

    the problem is, if i change the page.php file, then all the other individual posts will change as well.

    I can't seem to figure out the conditional tags, and this did not work:

    <?php if( is_page('') ) {
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    if ( is_page() && !is_category('7') ) {
    <link rel="stylesheet" href="http://www.sayuncleinc.com/wp-content/themes/pride/style2.css" type="text/css" media="screen" />
    <?php }

    so i have no clue what to do.. How can i use the conditional tags to change the style sheet when you are viewing a specific post from a specific category?

  2. funkyvega
    Posted 8 years ago #

    just realized i should be using the single.php file to make changes. But i believe it still does not work.

    however, i added that code above to the header.php file, trying to change the stylesheet.

  3. alanft
    Posted 8 years ago #

    read http://codex.wordpress.org/Conditional_Tags carefully - it's full of good stuff

    When the archive page for Category 9 is being displayed.

    Returns true if the current post is in the specified category id

  4. funkyvega
    Posted 8 years ago #

    ahhh ok.. is instead of is_category, i should use in_category?

    sweet... but should i be using the same code as above in the header file? I can't figure out how to link to the second style sheet.

  5. moshu
    Posted 8 years ago #

    Also, you may consider to take a look at this plugin:

  6. Rich Owings
    Posted 7 years ago #

    I want to do the same thing. Where does the code with the conditional tags go? In the loop?

    EDIT: Actually, I'm not concerned about stylesheets, but I do want all posts in a specific category to use a custom template.

Topic Closed

This topic has been closed to new replies.

About this Topic