Custom Php code in sidebar
-
Hi
I am developing a blog for multiple authors. I want to display some other post list of a specific author in the sidebar when anyone open a post. I have used couple of plugins like similler post and other but it didnot work. Then i used the follwing code: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>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');
which works fine and shows other post of a specific author. But it shows the post list under the single post. I want it to show in in sidebar
Need some suggestions. Please help
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Custom Php code in sidebar’ is closed to new replies.