Mixed post styles in a date archive? (9 posts)

  1. Arlo
    Posted 10 years ago #

    I have two post styles, depending on the category. I have no problem with displaying them properly in the category template inside the loop, I'm using a simple if..else to use the appropriate html:

    <?php if ( is_category('foo')) { ?>
    Category Foo's html
    <?php } else { ?>
    Other category's html
    <?php } ?>

    The problem is, I want to achieve similar results in the archive.php, whereby the category listing styles will intermingle. Archive.php seems only to allow is_category()`, which is useless for this purpose. Any ideas how I might make this work?


  2. Lorelle
    Posted 10 years ago #

    Have you checked out the http://codex.wordpress.org/The_Loop_in_Action article? It has some great suggestions for things like this.

    By adding more if/else statements to your loop, you can customize any of your template files. So it isn't the "categories" doing the styling but the template file and the styles attached to the header of that template set.

  3. Arlo
    Posted 10 years ago #

    Yes, I've read through the codex, but I can't seem to come up with a combination of tags and if/else that will actually let me differentiate the category of a post in the archive template.

    BTW, I made an error in my first post: Archive.php only allows is_archive()

  4. Lorelle
    Posted 10 years ago #


    And this didn't help?

    OH, wait a minute. You want the archive to display, but a particular category listed on the archive you want to look different from the rest of the categories listed on the archive. Is that it?

    So when you click the month of the archives list, anything that is in category X will look different from categories Y and Z?

  5. moshu
    Posted 10 years ago #

    Yes, I guess that's what he(?) wants, but I don't remember anything that would make that possible.

  6. Lorelle
    Posted 10 years ago #

    Moshu, do you know if the categories, when displayed on an archive (I don't have one), have some CSS references in them, like post-id?

    That would make it easy.

  7. Arlo
    Posted 10 years ago #

    Lorelle and moshu, yes, that's exactly what I want to do. It sounds like this isn't possible though. That and my dreams of list_cats showing individual category images are dashed. Oh well.

    Oh, and it's "he" :)

  8. Lorelle
    Posted 10 years ago #

    Well, if you look at this custom category page on my site, you will see wp_list_cats() featuring a list of the categories, with the subcats (children) looking different from the first level list categories. But this is styled with a DIV and using UL LI nested lists to make the different levels look different.

    Not exactly what you want, but a point in the right direction.

    Category images???? That's a different ball of wax. You can find a list of Image Plugins here that include ones that feature category images that might help you. I thought you wanted the text in the excerpt or title to look different per category when viewing an article.

  9. Arlo
    Posted 10 years ago #

    Ok -sorry, I confused two separate issues with my last post. :\

    This is my site: http://www.automatorworld.com
    As you can see, I have two visual styles for posts-- the "Headlines" style on top, and "Workflows & Actions" style on the bottom (the index has two loops). For single post and category pages it's of course easy to separate the styles, but searches and archives, where the returned posts intermingle, is where I wanted the logic to use the separate divs per post.

    The image thing: I'm using c2c-the-category-image throughout the site, particularly those little category icons in the header of each post. I want to have those same icons next to their category names in the sidebar (as in the top "Categories" heading) , but of course c2c only works in the loop.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.