Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Bubbajuju on "Add Classes or Id's to Related Author Posts Code"

$
0
0

I am trying to understand how to add a class to php so I can then style it with css.

Here is the code I am working on. I would like to style the post name and the thumb.

Thanks for any help as usual...

function get_related_author_posts() {
    global $authordata, $post;

    $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );

    $output = '<ul>';
    foreach ( $authors_posts as $authors_post ) {
        $output .= get_the_post_thumbnail($authors_post->ID);
        $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
    }
    $output .= '</ul>';

    return $output;
}

Viewing all articles
Browse latest Browse all 8245

Trending Articles