WordPress.org

Ready to get started?Download WordPress

Forums

Category specific coloring? (14 posts)

  1. ned4spd8874
    Member
    Posted 3 years ago #

    This seems like a simple thing to do, but I can't get it figured out. I would like the title color of posts be dependent on which category they are in.

    For example, post 1 is in category a; so the title should be green. Post 2 is in category b, so the title color should be red.
    Is this possible? What am I missing here? Thanks!

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try and use post_class() in the div of your posts:
    http://codex.wordpress.org/Function_Reference/post_class

    have you checked - your theme might already be using it?

  3. ned4spd8874
    Member
    Posted 3 years ago #

    Well I *kinda* got it working. But not really. How do I specify that only the title be a certain color? I got it so that the brief description text is colored. But that's not quite what I had in mind.

    http://myworthlesscrap.com/WordPress/

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try and use more specific css styles, such as:

    .category-stingers .entry-title a:link { color:green; }
    /*optional the hover state*/
    .category-stingers .entry-title a:hover { color:blue; }

    (you need to style the link, as it would otherwise be overwritten by the other styles for links)

  5. ned4spd8874
    Member
    Posted 3 years ago #

    Thanks, I tried your links (I had everything but the a:link part), but it still will not work for me. Any other ideas on how to get this to work??

  6. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    refresh your browser cache by pressing the 'reload' button; or by pressing 'ctrl' nad 'f5' simultanoulsy.

  7. ned4spd8874
    Member
    Posted 3 years ago #

    I've tried that. I opened the page in Firefox and I do see the colors. However, Chrome and IE won't though. And FF only shows it on the main page and nowhere else. Any suggestions on how to make it more universal and compatible with all the browsers?

  8. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    try without the :link bit; for instance:

    .category-stingers .entry-title a { color:green; }

    i assume, otherwise the styles get owerwritten by some a:visited style.

    or build :hover and :visited styles for your colored titles: http://wap.w3schools.com/css/css_pseudo_classes.asp

  9. ned4spd8874
    Member
    Posted 3 years ago #

    Ah, that got it!

    Again though...kinda. Still not showing up on the category pages that I created. I'm using azindex for the pages...still gotta figure that out. Ug.

    Thanks for your help so far, I really appreciate it!

  10. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    i get the coloring in the category archive pages as well -

    i assume, your browser caches are holding on to old stuff quite well.

  11. ned4spd8874
    Member
    Posted 3 years ago #

    I guess! Something is going on. I checked with Chrome, FF and IE and none of them show coloring on any category pages. I'll have to check at work to see what it look likes there.

    Thanks for all of your help!

  12. ned4spd8874
    Member
    Posted 3 years ago #

    Wait, I just figured out what you were talking about. Yes, I see the coloring if I click on the category links on the left side of the page. But if you click on the top links, the colors don't know. That's the next thing I need to fix.

  13. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    i was focussing only on the post titles.

    the cetegory menu in the sidebar has css classes for .cat-item-8 etc, where the number is the category id.

    because these are links as well, you need to style .cat-item-8 a etc.

    the top menu has individual css classes with ids, but unrelated to any category id:

    for instance .menu-item-208 for the 'stingers' tab.

    you can find these when you look into the html code of your site in your browser ('view source' or similar)

  14. ned4spd8874
    Member
    Posted 3 years ago #

    Sorry, I'm still struggling to figure this out. If I click on the top menu stingers, everything that is on that page doesn't have the green color. Which isn't a huge deal I guess, because the word is right there. So people will know by looking at the title.

    But if someone clicks on movies, then how can I set it up so that the title are the proper color? There will be a mixture of different categories that they will belong to. So even if I configure the css for everything under movies to have a certain color, that would be wrong. I need it to recognize which categories each page is under and color the titles accordingly.

    Sorry, I'm not a noob at web development and wordpress, but I obviously still have a long way to go before I can figure this sort of stuff out on my own.

Topic Closed

This topic has been closed to new replies.

About this Topic