Remove custom body class from pages with a specific category wordpress

wordpress add body class from page template
wordpress add body class to specific page
custom body class wordpress
body_class not working
wordpress add body class plugin
add class in body_class wordpress
add multiple classes to body wordpress
how to add class in wordpress

I am trying yo Remove custom body class from pages with a specific category in WordPress.

Here is the code below I am trying to make to work. However, it does not.

   function remove_body_class($wp_classes) { 
    if ( is_category ('places') ) :
    foreach ( $wp_classes as $key=>$value ) {
       if ( $value =='my_class' ) unset( $wp_classes[ $key ] );}
    endig;
return $wp_classes; 
}  add_filter( 'body_class', 'remove_body_class');

It works when I remove class from all pages without using "if ( is_category ('places') ) :"

But I can't make it work only for specific category/posts.

Could you tell me if I do something wrong? I would highly appreciate it.

Thank you.

it will be help for you.

// Removes a class from the body_class array.

add_filter( 'body_class', function( $classes ) {
    if ( isset( $classes['your-class-name'] ) ) {
        unset( $classes['your-class-name'] );
    }
    return $classes;
} );

Remove classes from body_class, You can configure the $whitelist array in this function to filter out all other unwanted classes. add_filter( 'body_class', 'wpse15850_body_class'� Step #2. Get the unique class from the body tag. Look for a unique class printed inside the body tag. In this context, a unique class is exclusive to this URL, which means that it doesn't exist on other pages. In my example below I have the .postid-1762 class, which refers to the post id.

// 34 is your category id
if (is_category('34')) 
{
    add_filter( 'body_class', function( $classes ) {
        if ( isset( $classes['your-class-name'] ) ) {
            unset( $classes['your-class-name'] );
        }
        return $classes;
    } );

}
// When the archive page for Category 34 is being displayed.

body_class() | Function, // Add specific CSS class by filter. add_filter( 'body_class' , function ( $classes ) {. Add one custom body class to the entire site, as well as additional classes only where needed by conditionally targeting the page slugs. In this example the site makes use of front end registration, login and password reset forms, so the goal is to modify the form styling only on these pages:

Define $cat_id to the category ID and change "your-class-name" to the name of the class you want removed:

if ( is_category($cat_id) ) {
    add_filter( 'body_class', function( $classes ) {
        if ( null !== array_search( 'your-class-name', $classes) ) {
            unset( $classes[ array_search( 'your-class-name', $classes) ] );
        }

        return $classes;
    } );
}

Remove Custom Header from Categories, Hi, I have managed to remove the custom header from specific pages, using the category CSS class set in the opening body html tag for all category pages. Styling the blog page. To style your Blog page with custom CSS on WordPress, i.e the page your blog posts are displayed on, you could use the following code:.blog h1 { font-size: 60px; } If this

Add Custom Body Class for Specific Pages, php file of your WordPress theme to replace your default HTML body tag. 1. < body <?php body_class(); ?>>� Thesis already creates a body class for pages (not posts) including pages for archives and categories. You can grab the auto generated body class for pages from the source code. If you use the field shown in the screenshot above, the default body class for pages will be overwritten with your custom class.

WordPress Body Class 101: Tips and Tricks for Theme Designers, Body Class (body_class) is a WordPress function that gives the body element You can customize specific author profile pages, date based archives etc. We suggested how about using the .category-slug body class to� You can delete categories in WordPress from the Posts>>Categories. All you have to do is hover over the WordPress category you want to delete. Then, click on the delete. Deleting any categories will not delete the post listed on it. All of the posts listed on that category will automatically be listed on the uncategorized by default. Change

Add Custom Body classes, Depending which page is visited, WordPress will output specific classes. 3) The body classes of the category archive pages are: Are you having trouble adding or removing body classes from your WordPress website? Using this class would apply the CSS rule ONLY to pages with this class in the Body element, and only pages which use the Page-Template file should be output with this class. With regard to WordPress posts, you can usually make use of classes such as: post-template-default, single, or single-post.

Comments
  • Hi, thank you! And what to do if I want to remove body class only from a specific category?