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

Hide posts and pages within the admin from users

wordpress snippet

I have had a few projects that required me to create a page that is for template use only. I may need to add shortcode or something to the page. Now since I don’t want my client to edit this page and possibly break things I hide the pages. Adding this snippet to the functions.php of your wordpress theme will allow you to add id’s for each of the posts or pages you wish to hide.

read more

Fix the read more link when using query_posts

wordpress snippet

When using query_posts to customize the query you may find that the “read more…” link no longer functions. Fixing this issue will require you to reset the $more variable. Add the following snippet just before the loop and things will start functioning properly again.

read more

Count posts, pages, comments and custom post types

wordpress snippet

This is a selection of snippets to display counts for posts, pages, custom post types, comments. Posts and pages have a publish and draft status while comment counts include moderated, approved, spam, trash, total.

read more

Auto link post thumbnails to the post permalink

wordpress snippet

Adding this code to the functions.php of your wordpress theme will Automatically link all post thumbnails to the post permalink.

read more

Most popular posts using views post meta

wordpress snippet

A few days ago Bob posted a comment asking about using the post views snippet to display the most popular posts. So here it is! place this snippet just before the loop within the index.php template and wordpress will use the post views to order your posts from highest to lowest. Don’t forget that for this to work you will need to setup the post views snippet.

read more

Adding page numbers to category, tag and post titles

wordpress snippet

Add this snippet to the title tag and meta descriptions to avoid duplicate content. Place within the header.php and Page 2 or above will be added to your wordpress pages.

read more