make acf field sticky at top of random search results
-
I have a custom post type with a acf field ‘featured’. If this field is ‘true’ I want the relevant posts to show sticky at the top of search results in a RANDOM order.
The rest of the results should be show randomly below the ‘featured’ results.I have the following code to show the search results randomly:
add_filter('posts_orderby', 'edit_posts_orderby'); function edit_posts_orderby($orderby_statement) { if(!is_admin()')) { $seed = $_SESSION['seed']; if (empty($seed)) { $seed = rand(); $_SESSION['seed'] = $seed; } $orderby_statement = 'RAND('.$seed.')'; } return $orderby_statement; }I want to add to it somehow the above conditions I described.
get_post_meta( $hit->ID, "_featured", true );
how do I do this?
- The topic ‘make acf field sticky at top of random search results’ is closed to new replies.