wordpress snippets last updated   : October 6, 2014
we now have 641 snippets

Display posts in a random order, but retain persistent pagination

wordpress snippet

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.

read more

Change admin area “pagination” posts per page

wordpress snippet

Adding this snippet to the functions.php of your wordpress theme will let you adjust the number of posts display within the admin area. By default wordpress will display 20 posts at a time within the admin area but you can change the number for the variable $per_page to display more or less.

read more

Add pagination to your blog

wordpress snippet

Add the first block of code to the functions.php of your wordpress theme, then just add the my_paginate_links() function in the location you wish to have your pagination appear.

read more
jqsnipp.com | we just launched jquery snippets website