Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to add the USER_ID to the body tag ??


  • r083r7
    Participant

    @r083r7

    Hello everyone,

    I’ve been trying to figure out how to include the user ID of the profile I’m looking at in the class body tag. The reason is that there’s 1 user that’s special and I need to style their page differently. I want to target the page by their user ID and trying to put it in the body class tag when viewing their profile.

    The closest code I found is this:

    ‘// Add user id CSS class via http://codex.wordpress.org/Function_Reference/body_class

    add_filter( ‘body_class’, ‘my_class_names’ );
    function my_class_names( $classes ) {
    // add ‘class-name’ to the $classes array
    global $current_user;
    $user_ID = $current_user->ID;
    $classes[] = ‘user-id-‘ . $user_ID;
    // return the $classes array
    return $classes;
    }’

    Close but not quite what I need. This code displays the user ID of the logged-in user (me). Instead, I need to show the user ID of the member’s profile when I’m viewing their profile. Any idea on how to adjust this code to do that?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar