wordpress snippets last updated   : April 14, 2014
we now have 630 snippets

Automatically link twitter usernames in posts

wordpress snippet

Excellent snippet by Paul Underwood that will automatically link twitter usernames in your posts. This snippet will look for text like @wpsnipp and convert it to <a href="http://twitter.com/wpsnipp">@wpsnipp</a> something I’m sure many of you will find useful.

read more

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

Post Meta.. The most valuable resources

tutorials
disable-wordpress-automatic-updates

Now that you have a decent understanding of meta data, how to save it and display it, let’s review some good tools for helping us manage the display and saving of our meta data.

read more

Add post category to body_class on single posts

wordpress snippet

This little snippet will take all the categories assigned to a post and add them to the body_class “sgl-cat-{category-name}”.

read more

Post Meta.. Let’s make something!

tutorials
post-meta-lets-make-something

Now that we’ve covered the fundamentals of what post meta is and how to use the functions to save and retrieve it, let’s take that information and make something useful. In this article, we’ll cover adding a metabox to the WordPress post editor screen, adding an input to that metabox for entering the post subtitle, and then saving it when the user saves/updates the post. We won’t go into depth in this post
about the many other functions used here, but you can find a wealth of information about them on the Codex.

read more

Disable wordpress automatic updates

wordpress snippet

One liner you can add to your wp-config to disable automatic updates. Sometimes you are just not ready to update to the next version of wordpress or want to update on your own schedule.

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