I’m using a post order plugin to have some sticky posts and those that aren’t marked as sticky are randomized using the code below
function randomize_order_with_sticky_on_top ( $post_list, $sort_view_id, $orderBy, $query )
{
shuffle($post_list);
//retrieve the sticky list for current sort ID
$sticky_list = get_post_meta( $sort_view_id , '_sticky_data', TRUE);
if ( ! is_array ( $sticky_list ) || count ( $sticky_list ) < 1 )
return $post_list;
//remove the sticky items in the $post_list
foreach ( $sticky_list as $position => $object_id )
{
if ( isset ( $post_list [ $object_id ] ) )
unset ( $post_list [ array_search( $object_id, $post_list ) ] );
}
$post_list = array_values ( $post_list );
foreach ( $sticky_list as $position => $object_id )
{
// Insert the ID at the specified position
array_splice( $post_list, $position - 1, 0, $object_id );
}
return $post_list;
}
Each post has a custom field checkbox that can have multiple values, let’s say blue, red and green. They can have combinations of all three values. What like I’d to do is have posts that have the value “green” weight higher than the rest so say any post that has green will be in the top 50% of the randomized order that isn’t sticky. Each time I try a variation it either doesn’t weigh the custom post type or it breaks the sticky feature. Any ideas would be great.