One post per author
-
Hello,
I modified a function of the rpwwt plugin to show the post author’s avatar.
private function the_first_post_image () { echo get_avatar( get_the_author_meta('user_email'), $size = '64'); return true; }It will not be orthodox but function because I don’t use “first post image” features.
Now I would like, however, to show only the last post of the author so that even if he has written 10 in a row, I occupy only one place, leaving evidence also to the other authors.
I found this piece of code online but I wouldn’t know how to implement it.
global $wpdb; function one_post_per_author_post_where($where) { global $wpdb; if(!is_author() && !is_admin()) { return $where .= " AND wp_posts.id = (select id from {$wpdb->prefix}posts p2 where p2.post_status = 'publish' and p2.post_author = {$wpdb->prefix}posts.post_author order by p2.post_date desc limit 0,1)"; } } add_filter("posts_where_request", "one_post_per_author_post_where");probably, I add, we will have to put somewhere …
remove_filter('posts_where_request','one_post_per_author_post_where');Someone could help me?
Bye!
thank you
math
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘One post per author’ is closed to new replies.