Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

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

[SOLVED] Add a Post’s Category Name to Body Class


  #1  
Old Feb 21, 2013, 12:28 AM
johnnybravo
 
36 posts · Apr 2011
Russia
Hi from Russia.
How to Add a Post’s Category Name to Body Class?
I need it for customize menu.
I found only this example:
Code:
function add_category_name($classes = '') {
   if(is_single()) {
      $category = get_the_category();
      $classes[] = 'category-'.$category[0]->slug; 
   }
   return $classes;
}
add_filter('body_class','add_category_name');
Can this code help me? Where i have to insert this code? functions.php?
  #2  
Old Feb 21, 2013, 03:40 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
Where did the place you found the code snippet suggest you put it?
Did you try it?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Feb 21, 2013, 04:22 AM
johnnybravo
 
36 posts · Apr 2011
Russia
Here
I did not try, because I do not know where to insert this code.
  #4  
Old Feb 21, 2013, 04:41 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
That link tells you where to put the snippet.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Feb 21, 2013, 05:22 AM
johnnybravo
 
36 posts · Apr 2011
Russia
Thanks!!! It works!!! Now in body classes i can see class - "category-name" and in css i added some style for this category. Cool!!!

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Post Body Content Missing & Category Pages 404 MichaelNagel Center area post/pages 11 Aug 11, 2012 03:22 AM
How to remove body text from category view? thesis Atahualpa 3 Wordpress theme 4 Nov 21, 2009 07:31 AM
something between the body of the post and post title ireneeng New Versions, & Updating 1 Nov 9, 2009 04:30 PM
[SOLVED] Can't change post titles? = Atahualpa Post Option->Body Title Single Pages? Muncheys New Versions, & Updating 2 Nov 8, 2009 07:17 AM


All times are GMT -6. The time now is 12:34 PM.


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