Community Forums › Forums › Archived Forums › Design Tips and Tricks › Images in post titles for different categories.
Tagged: blissful, category images
- This topic has 7 replies, 2 voices, and was last updated 11 years, 8 months ago by
Brad Dalton.
-
AuthorPosts
-
August 19, 2013 at 11:17 am #57354
krystyn
ParticipantThe 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,
http://www.sweetbeanhome.com
.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;
}August 19, 2013 at 2:41 pm #57411Brad Dalton
ParticipantI 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.
August 20, 2013 at 1:17 pm #57632krystyn
ParticipantHmmm..okay, thanks!
It's strange it works on category pages and the home pages, but it defaults to only one on a post page.
August 20, 2013 at 3:13 pm #57726Brad Dalton
ParticipantWhat you want to to do is display the same image for category archives on all posts in that same category?
August 20, 2013 at 6:24 pm #57805krystyn
ParticipantYes, same on category archives (which I have) as well as on individual posts, which is defaulting to the main one.
August 21, 2013 at 4:07 pm #58043Brad Dalton
ParticipantAll 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?
August 21, 2013 at 5:21 pm #58066krystyn
ParticipantI 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.
August 21, 2013 at 5:37 pm #58070Brad Dalton
ParticipantI 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
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.