-
AuthorPosts
-
November 2, 2016 at 7:57 pm #707324
Hi, I am looking to make some style changes to a post in a certain category. I saw in this post https://kriesi.at/support/topic/different-category-different-style-border-hover/ that there should be a category class added to the body tag, however, in my case, the class is added to the article tag, which is lower in the page than the style I need to adjust. Can you tell me how to make sure that my category class is added to the body tag, so it can be used for the entire page layout? I am using Enfold 3.8 and WP 4.6.1. Thanks, and I hope this makes sense!
November 2, 2016 at 11:10 pm #707416Hey janetgot,
We will surely help you, would you mind providing a precise link to your site, showing the elements in question? We need to be able to inspect them in order to help :)
Best regards,
VinayNovember 2, 2016 at 11:27 pm #707426Hi, yes, thanks, I’ve included it in the private content…. This is a link to a prototype post, and for all the posts in this category, I’d like to move the content up by removing the top padding of the content class.
Actually this page is using the Avia Layout, and with that the category isn’t showing up as a class at all. If I just add a post without the avia builder, the category is in the article tag, as in the second link. We want to use the avia builder so we can use a full width banner.
November 3, 2016 at 12:21 am #707442Hi!
You can inspect elements and target using post ID – http://i.imgur.com/WlYgnPS.png
.single.postid-452 { opacity: 0.6; }
Regards,
YigitNovember 3, 2016 at 1:21 am #707455Yes, but then I’d have to add a class every time I added a new page, which isn’t the question. I thought that a category class was added to the body tag, so I could set a style for every post in a category.
November 3, 2016 at 1:59 am #707460Hi!
Please add following code to Functions.php file in Appearance > Editor
add_filter('body_class','avia_single_body_categories'); function avia_single_body_categories($classes, $class) { if (is_single()){ global $post; foreach((get_the_category($post->ID)) as $category) { $classes[] = $category->category_nicename; } } return $classes; }
Cheers!
YigitMay 8, 2019 at 10:51 pm #1098665For custom taxonomies you can use this one
https://gist.github.com/ChrisLTD/5895564May 9, 2019 at 2:54 pm #1098929 -
AuthorPosts
- You must be logged in to reply to this topic.