Code Snippets

Saving useful code as I find it, build it, or stumble into it.

Fork Me on GitHub

Exclude Post Types From Search

This snippet allows you to remove a post type, like pages, for instance, from the search results without removing any others (by default WordPress searches posts, pages, and attachments). This will also preserve any custom post types you might have that are searchable (like those from other plugins).

Get Post Types By Taxonomy

Get post types that have a specific taxonomy, returns an array of objects or names, or false if nothing found.


Checks if the current post is a custom post type, returns boolean. Very handy when working with custom post types, layouts and the like.