WP - display author/title/avatar by posd id

by 4 replies
5
How can I display the author, title, and avatar of a post by id number?

Note:
I want to display these elements of several DIFFERENT posts in one page.

Thanks in advance for any help!
#programming #author or title or avatar #display #posd
  • you can use function the_author(); in loop.
    thie function display the author name by post-id parameter. but you should put it in a loop.
  • Figured it out.

    In case nayone needs it:

    <?php
    $post_id2 = get_post_meta($post->ID, 'bottom_img_excerpt1', true);
    $queried_post = get_post($post_id2);
    $author_id = $queried_post->post_author;
    $user_info = get_userdata($author_id);
    $first_name = $user_info->first_name;
    $last_name = $user_info->last_name;
    echo get_avatar($author_id);
    $title = $queried_post->post_title;
    echo '<strong>' . $title . '</strong> <br />';
    echo "$first_name $last_name";
    ?>
    • [ 1 ] Thanks
    • [1] reply

Next Topics on Trending Feed