Hi taadike,
Doesn’t it search in published posts only?
It does. I’m talking about the Order shortcode.
(“Start searching for related posts from latest post date, oldest post date or randomly.”)
But I want it to start searching for related posts from CURRENT post date.
Not latest, not oldest. I want to display only the related posts that are older than the Current post.
Is there any way to do that?
Try it with this in your (child) theme’s functions.php file:
add_filter( 'related_posts_by_taxonomy_posts_where', 'rpbt_future_related_posts', 10, 4 );
function rpbt_future_related_posts( $where_sql, $post_id, $taxonomies, $args ) {
global $wpdb;
$post = get_post( $post_id );
// Get posts older than current post date.
$where_sql .= " AND $wpdb->posts.post_date <= '{$post->post_date}'";
return $where_sql;
}
btw:
consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.