Skip to content

Commit

Permalink
Manual posts added after shuffle
Browse files Browse the repository at this point in the history
Fixes #148
  • Loading branch information
ajaydsouza committed Nov 13, 2021
1 parent 356a3cb commit ab46079
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions includes/class-crp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,11 @@ public function the_posts( $posts, $query ) {
set_crp_cache( $this->source_post->ID, $meta_key, $post_ids );
}

// Shuffle posts if random order is set.
if ( $this->random_order ) {
shuffle( $posts );
}

// Manual Posts (manual_related - set via the Post Meta) or Include Posts (can be set as a parameter).
$post_ids = array();

Expand All @@ -702,11 +707,6 @@ public function the_posts( $posts, $query ) {
$posts = array_merge( $extra_posts, $posts );
}

// Shuffle posts if random order is set.
if ( $this->random_order ) {
shuffle( $posts );
}

/**
* Filter array of WP_Post objects before it is returned to the CRP_Query instance.
*
Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ You can insert the related posts anywhere in your post using the `[crp]` shortco

* Bug fixes:
* Don't enqueue wp-editor on widgets.php
* [WP_Query stopwords](https://developer.wordpress.org/reference/classes/wp_query/get_search_stopwords/) are stripped from content that is matched.
* [WP_Query stopwords](https://developer.wordpress.org/reference/classes/wp_query/get_search_stopwords/) are stripped from content that is matched
* Manual posts are added after the automatic posts are shuffled

= Earlier versions =

Expand Down

0 comments on commit ab46079

Please sign in to comment.