title: How to display related post by categories with next post of current post (don't latest post or random post)
body: <p>How to display related post by categories with next post of current post (don't latest post or random post). I'm use code related post for twentytwelve theme. but now, author in wentytwelve_entry_meta() is repeat.</p>
  
  <p>pls help me :</p>
  
  <pre><code>&lt;div id="related_posts"&gt;
      &lt;?php
          $categories = get_the_category($post-&gt;ID);
          if ($categories) {
              $category_ids = array();
              foreach((get_the_category()) as $category) {
                  $id = $category-&gt;cat_ID;
              }
              global $wpdb;
              $query = "
                  SELECT * FROM $wpdb-&gt;posts
                  LEFT JOIN $wpdb-&gt;term_relationships ON
                  ($wpdb-&gt;posts.ID = $wpdb-&gt;term_relationships.object_id)
                  LEFT JOIN $wpdb-&gt;term_taxonomy ON
                  ($wpdb-&gt;term_relationships.term_taxonomy_id = $wpdb-&gt;term_taxonomy.term_taxonomy_id)
                  WHERE $wpdb-&gt;posts.post_status = 'publish'
                  AND $wpdb-&gt;term_taxonomy.taxonomy = 'category'
                  AND $wpdb-&gt;term_taxonomy.term_id = $category_ids[0]
                  AND $wpdb-&gt;posts.id &lt; $post-&gt;ID
                  ORDER BY id DESC limit 3
             ";
             $my_query = $wpdb-&gt;get_results($query);
             if( $my_query) {
                 echo '&lt;h3&gt;Related Posts&lt;/h3&gt;&lt;ul&gt;';
                 foreach($my_query as $key =&gt; $post) {
                 ?&gt;
                     &lt;li&gt;
                          &lt;div class="entry-header"&gt;
                              &lt;div class="header-l"&gt;
                                   &lt;h1 class="entry-title"&gt;
                                        &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?&gt;" rel="bookmark"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                                  &lt;/h1&gt;
                                  &lt;p class="datetime"&gt;
                                      &lt;?php twentytwelve_entry_meta(); ?&gt;
                                  &lt;/p&gt;
                              &lt;/div&gt;
                              &lt;?php the_post_thumbnail(); ?&gt;
                        &lt;/div&gt;
  
                        &lt;div class="entry-summary"&gt;
                            &lt;?php
                                $str_content = wp_trim_words($post-&gt;post_content);
                                $str_content = str_replace('[', '&lt;', $str_content);
                                $str_content = str_replace(']', '&gt;', $str_content);
                                echo $str_content;
                            ?&gt;
                       &lt;/div&gt;
                  &lt;/li&gt;
             &lt;?php
             }
             echo '&lt;/ul&gt;';
         }
     }?&gt;
  </code></pre>
  
  <p></p>