ThemeShaper Forums » Thematic

[closed]

How best to create a separate style for one specific category and all it's post?

(9 posts)
  • Started 2 years ago by kim4true
  • Latest reply from helgatheviking
  • This topic is resolved
  1. I've created a theme for an author. She asked for just the books to appear on the home page with bluebonnets for the style and colors. (see www.debraclopton.com/w)

    I managed to do that and in the process created a custom home page loop and an options panel in the back end that will allow her to switch to a different pink/purple style if she changes her mind.

    Now she wants to be able to have her personal blog pages ONLY display using the pink style sheet. I'm scratching my head over the best way to approach this. I'd like to be able to create a dummy proof way for her to switch just this category and all its associated single post pages back and forth between styles.

    Suggestions?

    Posted 2 years ago #
  2. I created a page using the alternate stylesheet to displays her blog, http://debraclopton.com/w/?page_id=658, and that would almost do the job, but I can't get the other regular links to the category and category single posts to display using this stylesheet.

    Also, this page is displaying ALL posts, and I have not yet been successful in making it display only the 'blog' category.

    Posted 2 years ago #
  3. Here's my code for the one page I have working with the alternate stylesheet:

    ==========================================

    //alternate stylesheet for blog page
    function my_stylesheet($content) {
    global $wp_query;
    if (is_page()) {
    $pageID = $wp_query->post->ID;
    $pagelist = array('658');
    if (in_array($pageID, $pagelist)) {
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style-blog.css";
    $content .= "\" />";
    $content .= "\n\n";
    }
    }
    return $content;
    }
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');

    ======================================

    Have been trying to get this to work, but am missing something vital:

    ======================================

    //alternate stylesheet for blog single page
    add_filter('single_template', create_function('$t', 'foreach( (array)
    get_the_category() as $cat ) { if ( file_exists(STYLESHEETPATH . "/single-{$cat->slug}.php") ) return STYLESHEETPATH . "/single-{$cat->slug}.php"; } return $t;' ));

    Posted 2 years ago #
  4. http://programming.thematic4you.com/2010/01/how-to-use-a-different-layout-for-a-certain-page/

    though it seems like you are already all over the thematic_create_stylesheet filter.

    why not use is_category() and/or in_category() as your conditionals?

    Posted 2 years ago #
  5. One problem seems always to lead to another!

    in_category() actually worked! but it also changes my home page, which is set up to work with an options panel.

    I know I need to tell it that if it's the home page, to use the blue stylesheet - but I'm not sure of the syntax.

    =========================

    // custom homepage loop
    function authorsite_indexloop() {

    // load the custom options
    global $childoptions;
    foreach ($childoptions as $value) {
    $$value['id'] = get_option($value['id'], $value['std']);
    }

    query_posts("posts_per_page=4&cat=" . $authorsite_feature_cat);
    $counter = 1;
    if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
    <?php thematic_postheader();
    if ($counter == 1 && has_post_thumbnail() && !is_paged()) {
    the_post_thumbnail('homepage-thumbnail');
    } ?>
    <div class="entry-content">
    <?php the_excerpt(); ?>
    " class="more"><?php echo more_text() ?>
    <?php $counter++; ?>
    </div>
    </div><!-- .post -->
    <?php endwhile; else: ?>
    <h2>Eek</h2>
    <p>There are no posts to show!</p>
    <?php endif;
    wp_reset_query();
    }

    //alternate stylesheet for blog page
    function my_stylesheet($content) {
    if (in_category('3')) {
    $content = "\t";
    $content .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
    $content .= get_bloginfo('stylesheet_directory') . "/style-blog.css";
    $content .= "\" />";
    $content .= "\n\n";
    }
    return $content;
    }
    add_filter ('thematic_create_stylesheet', 'my_stylesheet');

    ================================

    I'd still like to get this one category into the options panel as well... The website owner is now saying "just leave it all blue," but I'm determined! I've gone this far with it, I want to get it completely done.

    Thanks so much for your help helgatheviking.

    Posted 2 years ago #
  6. u modified your loop for the whole site or just for the blog page? if the look works normal in other pages u could do this

    if (in_category('3') && !is_front_page()) {

    Posted 2 years ago #
  7. Hi red 23, I modified just the loop for the home page, but the alternate stylesheet should NOT be associated with the homepage, only with the category 3.

    I am thinking the confusion is because the home page stylesheet is determined by an options panel.

    How would I make this say is NOT front page?

    && !is_front_page())

    Posted 2 years ago #
  8. Ignore my last post... I tried it, red23, and yes, that worked! Thank you.

    Posted 2 years ago #
  9. does that mean you've solved it? if so, can you mark the thread as resolved.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.