wordpress snippets last updated   : January 29, 2015
we now have 646 snippets

count_user_posts by user ID and by post_type

wordpress snippet

You may be aware that count_user_posts has been around since about 3.0. However as of 4.1 you are able to optionally define a post_type. This is a perfect little snippet if you have a blog with multiple post types and you wanted to show specific counts for authors. I could use something like this for WordPress snippets vs tutorials sections and it would be perfect. Just add this snippet in the template you wish to display the count and you are ready to go.

read more

Filter search results by post type

wordpress snippet

Adding this PHP code to the functions.php of your wordpress theme will only search posts, and custom post types, excluding pages.

read more