0

I want to list my authors with the title of their last post.

ı want to sample sort

user1, title1, date=19.10.2017 > user2, title2, date=17.10.2017 > user3, title3, date=15.10.2017

<?php
global $wpdb;
$results = $wpdb->get_results( "
SELECT * FROM wpig_users 
JOIN wpig_posts ON wpig_posts.post_author = wpig_users.ID
JOIN wpig_term_relationships ON wpig_posts.ID = wpig_term_relationships.object_id WHERE  term_taxonomy_id ='11'
ORDER BY post_date DESC LIMIT 10"  );



foreach($results as $res) { 

    //echo $res->col1;

    echo '<b>';
    echo $res->display_name;
    echo '</b> // ';
    echo $res->post_title;
    echo '<br>';
 }
?>

I could write a code like this. but this code takes the last posts and authors.

as in the picture

Note : the code I wrote does not list the last writers of all authors.

enter image description here

1 Answer 1

1

WordPress provides its own function to accomplish this:

get_most_recent_post_of_user( $user_id );

Source: https://codex.wordpress.org/Function_Reference/get_most_recent_post_of_user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.