WordPress.org

Forums

[resolved] adding username to post_class (2 posts)

  1. jbbrwcky
    Member
    Posted 6 years ago #

    Reading through the post_class() text, it appears you can use an array to put text in there, so like this:

    post_class('foo bar');

    That would be correct, and I have tested it out, and it works fine.

    How do I get the post's author's name in there though? I've tried using the_author_login() but it doesn't work. $post->post_author gives the ID, not the name. Can anyone help?

    Thanks,
    Richard

  2. jbbrwcky
    Member
    Posted 6 years ago #

    Ahh found a solution:

    $curauth = get_userdata(intval($post->post_author));

    Then use:

    post_class($curauth->user_login);

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic