Limit Search Form to Specific Post Types

If you’d like to limit the search form on WordPress site to specific post types globally, there’s and easy way to do that:

[gist id=”ca2f2dff2d6fde3bfd1e” file=”limit-search-to-post-types.php” lines=”2-9″]

But let’s say you want to have a specific search form search limited to one post type, but allow other search forms to search all post types?

Most tutorials I’ve run across suggest that you re-create all the search form markup and then add a hidden input to the form like this:

[gist id=”ca2f2dff2d6fde3bfd1e” file=”limit-search-to-post-types.php” lines=”12-13″]

You can then conditionally load that hidden field on the specific templates where where it is needed.

However, if you’re using get_search_form() and don’t want to completely replace all the search form markup, an alternative would be to do a string replace before outputting the form:

[gist id=”ca2f2dff2d6fde3bfd1e” file=”limit-search-to-post-types.php” lines=”15-22″]

For more reading on how this filter works, you can read the great inline docs in the WordPress codebase itself.

Better Blockquotes

WordPress has a button in the editor for adding blockquotes to a post. But what if an author wants to add a citation? Unfortunately, it’s not possible without a little HTML knowledge.

This is a problem I’ve thought about a bit when designing DevPress themes (what markup should I be styling for?), but it’s also come up on a few client projects recently. Citations are a pretty common use-case, and it would be great if they were easier to add.

My solution was to build a plugin that replaces the existing TinyMCE button for blockquotes with an enhanced one. Continue reading