• On my blog homepage I’m using a wp query to display 8 featured posts from an array. Now I’m trying to write a script that would randomly pick 3 elements out of the first 5 elements of the array and assign them a custom css class (.feat_large) and a specific post thumbnail the_post_thumbnail( ‘homepage-thumb-large’ ). Remaining 5 posts should use the the_post_thumbnail( ‘homepage-thumb-small’ ) and no specific css class.

    I managed to achieve something similar in JS, but now I’d like to have a server-side php solution. My knowledge of php is very limited, so I’d appreciate some help on this issue.

The topic ‘Selecting random posts from an array’ is closed to new replies.