WordPress.org

Ready to get started?Download WordPress

Forums

Related Posts Thumbnails
How to order posts by their dates??? (1 post)

  1. dytx
    Member
    Posted 1 year ago #

    Hi, I want related posts order by date. How to do it?
    I found a code below maybe cause the result:

    /* Get posts by their IDs */
    if ( !is_array( $random_posts ) || count( $random_posts ) < 1 ) {
    return $this->finish_process( $output, $debug . 'No posts matching relationships criteria;', $time );
    		}
    $posts_in = array();
    foreach ($random_posts as $random_post)
    	$posts_in[] = $random_post->ID;
    $query = "SELECT ID, post_content, post_excerpt, post_title FROM $wpdb->posts WHERE ID IN ('". implode( "', '", $posts_in ) . "')";
    $posts = $wpdb->get_results( $query );
    if ( ! ( is_array( $posts ) && count( $posts ) > 0 ) ) { // no posts
    	$debug .= 'No posts found;';
    	return $this->finish_process( $output, $debug, $time );
    }
    else
    	$debug .= 'Found ' . count( $posts ) . ' posts;';

    and I want the current post show up on list, too.
    Thx!

    http://wordpress.org/extend/plugins/related-posts-thumbnails/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.