Randomising the order of the returned posts in a WordPress query is easy – simply add
'orderby' => 'rand' to the arguments and you’re good to go – this is great, until you need to paginate the results. As soon as you navigate to the second page of the results, the posts are returned randomly once again and you get an entirely different set of posts that may or may not contain posts that you have already viewed – if you’ve experienced this before then you’ll know exactly how frustrating it can be. The first thing we need to do is make sure our PHP session is initiated and then we can use the
'posts_orderby' filter to handle the persistent randomisation.
With this little snippet you can add custom image sizes to media insert dialog box.
image_size_names_choose allows modification of the image size lists so that you can place a custom option within the media library.
this months featured snippets
Disqus outputting JS on parts of your wordpress website you don’t want? Adding this snippet to the functions.php of your wordpress theme will only output JS on is_singular posts or pages where comments are available.read more
WordPress 3.3+ has a core function called wp_trim_words() this function will trim text to a specified number of words and return the result. Adding this snippet to your wordpress loop will let you easily trim the number of words displayed within the_content, the_excerpt, the_title or any other value you pass to this core function.read more
Adding this snippet to the functions.php of your wordpress theme will create a new metabox within your post editing screen with a select menu listing all PDF files. Adding the second snippet in your wordpress template in the location you wish to display the files URL.read more
Adding this snippet to the functions.php of your wordpress theme will change the background colors of the post / page within the admin based on the current status. Draft, Pending, Published, Future, Private.read more