Removing custom body class

This topic contains 4 replies, has 3 voices, and was last updated by  Stiofan O’Connor 8 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #214391

    Egor Shvetsov
    Expired Member
    Post count: 24

    Hello, I am trying to remove a body class from all listing details pages, here is the code below I am trying to make to work.

    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 apply 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?

    Thank you.

    #214444

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Not tested but you might want to try our function

    geodir_is_page('detail')

    Stiofan

    #214491

    Egor Shvetsov
    Expired Member
    Post count: 24

    Hi Stiofan,

    It worked, thanks a lot!

    Final code for those in need:

    
    
    function remove_body_class($wp_classes) { 
            if (geodir_is_page('detail')) :
            foreach ( $wp_classes as $key=>$value ) {
               if ( $value =='custom_class' ) unset( $wp_classes[ $key ] );}
            endif;
        return $wp_classes; 
        }
    add_filter( 'body_class', 'remove_body_class');
    #214549

    Mario
    Expired Member
    Post count: 58

    may i ask for what purpose you wanna do that? Thx for answer.

    #214551

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Great! 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount