1
2
3
4
五
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 |
function wpb_related_author_posts( $content ) { if ( is_single() ) { global $authordata , $post ; $content .= '<h4>Similar Posts by The Author:</h4> ' ; $authors_posts = get_posts( array ( 'author' => $authordata ->ID, 'post__not_in' => array ( $post ->ID ), 'posts_per_page' => 5 ) ); $content .= '<ul>' ; foreach ( $authors_posts as $authors_post ) { $content .= '<li><a href="' . get_permalink( $authors_post ->ID ) . '">' . apply_filters( 'the_title' , $authors_post ->post_title, $authors_post ->ID ) . '</a></li>' ; } $content .= '</ul>' ; return $content ; } else { return $content ; } } add_filter( 'the_content' , 'wpb_related_author_posts' ); |