Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom classes for profile pages, possible?


  • jerryskate
    Participant

    @jerryskate

    Hi! I wonder if it would be possible to have every profil page their own classes for some css customizing?

    /Jay

Viewing 12 replies - 26 through 37 (of 37 total)

  • Henry Wright
    Moderator

    @henrywright

    Can you paste your code? The original classes shouldn’t be lost. The filter just adds new ones whilst retaining what classes are already in place.


    jerryskate
    Participant

    @jerryskate

    Well, i use the snippet in my bp-custom.php, which is empty except the snippet. i use the one you guys gave me. What code do you want me to paste, the header.php one?

    Thanks for the effort btw, much appreciated.


    food pyramid for kids
    Participant

    @food-pyramid-for-kids


    Henry Wright
    Moderator

    @henrywright

    @jerryskate if you could post your filter (what you have in bp-custom) and your body tag (from your header.php) i’ll take a look…

    cc @modemlooper @hnla – anyone for some healthy foods from the food-pyramid guy? I prefer a good old fashioned burger and fries myself 🙂


    jerryskate
    Participant

    @jerryskate

    This in bp-custom:

    function add_body_classes( $classes ) {
        if ( bp_is_member() )
            $classes[] = 'this-is-a-member-profile';
    
        if ( bp_is_member() )
        $classes[] = 'member-profile-of-' . bp_displayed_user_username();
    }
    add_filter( 'body_class', 'add_body_classes', 12 );

    jerryskate
    Participant

    @jerryskate

    And this in header:

    <body <?php page_bodyclass(); ?>>


    Henry Wright
    Moderator

    @henrywright

    In bp-custom right after the line $classes[] = 'member-profile-of-' . bp_displayed_user_username();

    add this:

    return $classes;


    jerryskate
    Participant

    @jerryskate

    Ok, a bit better 🙂 Still having my profilename outside the classes, but got all the old ones back.

    <body jerryclass="activity bp-user my-activity my-account just-me buddypress bbp-user-page single singular bbpress page page-id-5 page-template-default logged-in admin-bar no-customize-support bp-wall adminbar-enable not-responsive this-is-a-member-profile member-profile-of-" class=" customize-support" data-twttr-rendered="true">


    Henry Wright
    Moderator

    @henrywright

    OK, I think I might know what is happening. Try this as the whole thing put together:

    function add_body_classes( $classes ) {
        
        if ( bp_is_member() ) {
            $classes[] = 'this-is-a-member-profile';
            $classes[] = 'member-profile-of-' . bp_get_displayed_user_username();
        }
    
        return $classes;
    }
    add_filter( 'body_class', 'add_body_classes', 12 );

    jerryskate
    Participant

    @jerryskate

    Henry, your a genius! It works! It gave me .member-profile-of-jerry as a class to use. Finally! Thanks so much. I have one bug left to solve, a permalink issue, but won’t bother the forum until i tried deactivating plugins and some other things. Again, thanks!


    Henry Wright
    Moderator

    @henrywright

    @jerryskate great! glad you got it working 🙂


    jerryskate
    Participant

    @jerryskate

    Mee too 😀

Viewing 12 replies - 26 through 37 (of 37 total)
  • The topic ‘Custom classes for profile pages, possible?’ is closed to new replies.
Skip to toolbar