iftekharul

Get Related Author Posts

Sep 10th, 2015
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function t4b_get_related_author_posts() {
  2.     global $authordata, $post;
  3.     if(get_post_type() == 'quick-tips') {
  4.         $post_type = 'quick-tips';
  5.     } else { $post_type = 'post'; }
  6.     $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post_type' => $post_type, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 1 ) );
  7.     if($authors_posts) :
  8.     $output = '<div id="t4b-latest-tune">';
  9.     foreach ( $authors_posts as $authors_post ) {
  10.         $post_date = $authors_post->post_date;
  11.         $post_date = mysql2date('M j, Y g:i:s a', $post_date);
  12.         $postDate = $authors_post->post_date;
  13.         $hide_extra = get_date_time_count($postDate);
  14.         if ( has_post_thumbnail() ) {
  15.             $output .= get_the_post_thumbnail($authors_post->ID, 'sidebar-thumb');
  16.         } else {
  17.             $output .= '<img src="'.get_stylesheet_directory_uri().'/images/wp-logo.png" alt="TiPS4BLOG" />';
  18.         }
  19.         $output .= '<h4><a href="' . get_permalink( $authors_post->ID ) . '">';
  20.         $output .= apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></h4>';
  21.         $output .= '<p>' . $post_date . ' ( ' . $hide_extra . ' আগে )</p>';
  22.     }
  23.     $output .= '</div>';
  24.     else :
  25.         $output = '<div id="t4b-empty-tune">';
  26.         $output .= '<h4>*** এই ব্লগে এটাই আমার প্রথম টিপস ***</h4>';
  27.         $output .= '</div>';
  28.     endif;
  29.     return $output;
  30. }
RAW Paste Data