Images in post titles for different categories.

Community Forums Forums Design Tips and Tricks Images in post titles for different categories.

This topic is: not resolved

This topic contains 7 replies, has 2 voices, and was last updated by  braddalton 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #57354

    krystyn
    Participant
    Post count: 147

    The site is here.

    When you click on a link to the category, for example, http://www.sweetbeanhome.com/category/green-home/ you’ll see the correct image for that category.

    However when you click on a specific post in that category, for example: http://www.sweetbeanhome.com/green-home-test-post/, it uses the default image.

    I’ve been starring and playing with the code and I can’t figure out what I’ve got wrong. Any suggestions? It’s also displaying okay on the home page. Here’s a snippet:

    /*Green home*/
    .home #content .category-green-home h2 {
    background: #ffffff url(http://www.sweetbeanhome.com/wp-content/uploads/2013/08/green-house-post.jpg) no-repeat left;
    border-bottom: 1px solid #d597bf;
    height: 34px;
    /*margin: 0 0 10px -30px;*/
    padding: 13px 0 0 55px;
    }

    .page .category-green-home h1,
    .post .category-green-home h1,
    .archive .category-green-home h2 {
    background: #ffffff url(http://www.sweetbeanhome.com/wp-content/uploads/2013/08/green-house-post.jpg) no-repeat left;
    border-bottom: 1px solid #d597bf;
    height: 34px;
    /*margin: 0 0 10px -30px;*/
    padding: 13px 0 0 55px;
    }

    http://www.sweetbeanhome.com
    #57411

    braddalton
    Participant
    Post count: 8826

    I don’t think you can use CSS to display a different header image for posts in a category. Maybe wrong.

    What you can do is use PHP code with a conditional tag for in_category()

    Or you can use a plugin named wp display header. Its a well coded plugin authored by a Theme Wrangler at Automattic, Core Contributor to WordPress 3.4/3.5, Member of the WordPress Theme Review Team.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #57632

    krystyn
    Participant
    Post count: 147

    Hmmm..okay, thanks!

    It’s strange it works on category pages and the home pages, but it defaults to only one on a post page.

    #57726

    braddalton
    Participant
    Post count: 8826

    What you want to to do is display the same image for category archives on all posts in that same category?


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #57805

    krystyn
    Participant
    Post count: 147

    Yes, same on category archives (which I have) as well as on individual posts, which is defaulting to the main one.

    #58043

    braddalton
    Participant
    Post count: 8826

    All you need to do is use the right classes for single posts in a specific category but i don’t think this is possible as i tested over a dozen different options recently and did ask that question at the end of the post.

    I know its easily done using PHP or a plugin.

    Do you know which classes to use for single posts in a category?


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #58066

    krystyn
    Participant
    Post count: 147

    I would use is_single() for the post, but I’m not sure how to incorporate the in_category() part with it.

    I looked at the plugin, too and that should work. I guess I wanted to figure out the php part.

    #58070

    braddalton
    Participant
    Post count: 8826

    I think you may want to try out the plugin.

    Here’s some PHP code you can modify to suit your needs

    I think its best to use the same method. I.E. All CSS or all PHP code rather than CSS and PHP.

    https://gist.github.com/braddalton/6301615


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.