≡ Menu

Thesis 1.x – Add custom author class to body

The following code adds a custom body class to all posts and author pages in the form of author-# where # is the ID of the author.

function post_author_class($classes) {
    global $post;
    $post_author = $post->post_author;
    if (is_author() || is_single()) {
        $classes[] .= 'author-'. get_the_author_meta('ID', $post_author);
    }
    return $classes;
}
add_filter('thesis_body_classes', 'post_author_class');

Originally for http://diythemes.com/forums/showthread.php?60592-Trying-to-assign-Custom-header-images-for-Author-and-Posts-by-Author

Comments on this entry are closed.