Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Header configuration & styling »

[SOLVED] Getting single posts to inherit header for their category


  #1  
Old Jul 28, 2014, 05:36 PM
kitfreeman
 
56 posts · Jan 2011
I have created two virtual blogs from a single install, using two basic categories and a menu link to each category. Now I'd like to have a different header image (banner) for each virtual blog -- i.e., I'd like posts to show a different header image depending on whether they belonging to one basic category or the other.

I can get the effect I want for the category pages using the following CSS:

body.category-1 div#imagecontainer {
background-image: url(/wp-content/ata-images/banner-1.jpg) !important;}

body.category-2 div#imagecontainer {
background-image: url(/wp-content/ata-images/banner-2.jpg) !important;}

However, this doesn't work for single post pages, which revert to the default site banner. Is there a simple way I can get single post pages to inherit the header image assigned to the category to which they belong?

I'd be very grateful for any help! Thanks!

Best, Kit
  #2  
Old Jul 28, 2014, 06:32 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
that should work fine - what is the url pointing to the problem post?
also check the spelling of your category name in the css - computers are notorious for doing what you tell them to do and not what you want them to do.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Jul 28, 2014, 06:47 PM
kitfreeman
 
56 posts · Jan 2011
Thanks for your reply. It works fine for the general category link -- see here, but if I go to a specific post, it defaults to the site banner -- see here. I'd like specific posts to inherit the category banner. I guess this would require a body.single-post div#imagecontainer command, but I can't make it work. Obviously, I'd prefer not to have have to set the banner for each post individually!
  #4  
Old Jul 28, 2014, 07:16 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
edit functions.php and change line 991 (the last line) from
HTML Code:
?>
to
HTML Code:
// add category nicenames in body and post class
	function category_id_class($classes) {
	    global $post;
	    foreach((get_the_category($post->ID)) as $category)
	        $classes[] = $category->category_nicename;
	        return $classes;
	}
	add_filter('post_class', 'category_id_class');
	add_filter('body_class', 'category_id_class');
?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Jul 28, 2014, 07:28 PM
kitfreeman
 
56 posts · Jan 2011
Thanks. I've added that (to the functions.php in the ata them directory), but sadly it doesn't seem to be working, despite several page reloads
  #6  
Old Jul 28, 2014, 07:39 PM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
check the category slug and make sure it has no blanks in it - I see 'consciousness mind' and it should be 'consciousness-mind' and your CSS should reflect that.

also why are you using
HTML Code:
if (in_category('mind')) {
body.single-post div#imagecontainer {
background-image:url(/wp-content/ata-images/kf_banner-mind.jpg) !important
}
}
in your CSS? What do you think that will do?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Last edited by juggledad; Jul 28, 2014 at 07:43 PM.
  #7  
Old Jul 29, 2014, 08:42 AM
kitfreeman
 
56 posts · Jan 2011
Thanks. I can't see any gaps in the CSS category names. And the problem is there with posts that have only the basic category, like this test post.

I've removed the bit of CSS you noticed -- it was a left-over from an incompetent experiment! But do I need some CSS to get the single post effect (a body.single-post command?), now that the php code has been added?

Thanks for your time. As you can tell, I'm not very competent at this!
  #8  
Old Jul 29, 2014, 09:49 AM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I'd like to take a look because my site with multi word category names (ex 'word1 word2'), sets the slug as 'word1-word2' and sometimes yi u have 'word1-word2' but in the header it is 'word1 word2'

so I'd like to take a look at your site. If it is ok, please send me a PM with an admin ID/pw
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #9  
Old Jul 29, 2014, 11:07 AM
juggledad's Avatar
juggledad
 
23,655 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Ahhhh now I see what is happening

The category is 'mind' not 'category-mind' so your css selector of
HTML Code:
 body.category-mind div#imagecontainer {
will never work. You need to code it as
HTML Code:
 body.mind div#imagecontainer {
you should take a css tutorial (http://htmldog.com/guides/css/) and learn how to use a code editor so you can look and see what you are doing
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #10  
Old Jul 29, 2014, 12:17 PM
kitfreeman
 
56 posts · Jan 2011
That's cracked it! Thank you very much for your help. (And yes, I will take a tutorial!)

Bookmarks

Tags
header images

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem with header on single posts kal Center area post/pages 4 Jan 6, 2011 07:18 AM
Problem similar to "Recent posts of same category, on single post pages" sikedestroya Sidebars & Widgets 0 Aug 20, 2010 05:44 AM
[SOLVED] Recent posts of same category, on single post pages GeoParadise Atahualpa 3 Wordpress theme 10 Apr 19, 2010 08:54 AM
sidebars in single posts one parent category only. ortixia Sidebars & Widgets 1 Mar 7, 2010 05:10 AM
[SOLVED] Different template for single posts by category or other means greggman Center area post/pages 4 Feb 24, 2010 10:34 PM


All times are GMT -6. The time now is 10:50 PM.


Powered by vBulletin® Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.