List Authors by last_published column (1 post)

    Posted 2 years ago #

    I'm making a Author archive, and I'd like to order the authors by the last_published column. However I do not wish to use a SQL, but the WP_User_Query wich doesn't support last_published filtering or ordering.

    I'm thinking of using a meta_query instead, BUT how do I get the user_meta to add/update last_published column in wp_usermeta table only when the post is actually published?

    This is how far I've got, but the usermeta is only added/updated when the post is first created.

    function update_last_published($postid){
    	$post = get_post($postid);
    	$date = date('Y-m-d H:i:s');
    	update_user_meta($post['post_author'], 'last_published', $date);
    add_action('wp_insert_post', 'update_last_published');

Topic Closed

This topic has been closed to new replies.

About this Topic