Add WordPress Stop Words

Sometimes a client will want to prevent certain words from being included in or affecting the search results. In order to remove these words from the search query we can just add them to the WP_Query stopwords like so:

 

BBPress Filters

I have a tolerate/hate relationship with BBPress. I have worked with it a couple times now and I am not super happy with it. I think custom PHP forums or managed forums are better solutions when possible. Sometimes, they are not possible for some clients.

That said, using BBPress is FAR, FAR, FAR better than trying to build your own WordPress forum.

Here are some common filters I have used on BBPress to improve functionality.

 

Include Taxonomy Links in Search Results

By default WordPress (and many search plugins) will only find Posts associated with a category. So even if you search the exact category name, only posts which have that category will be listed.

We had a client that needed the category pages to be listed as well. Here is the solution I came up with to resolve that problem.

Step 1

Hook into our pre_get_posts and search our taxonomies with some custom queries.

 

Step 2

Attach the terms we found to our search results

 

Step 3

No code here, but just be aware that on your search page your $post object in the loop will not have “post_title” or other default post values. So you will need to check if the “$post” you are handling is a term and then set it up correctly.

Good luck!

Highlight and Locate Search Terms

Sometimes we have clients that want to give their users a little extra help in finding the search terms they are looking for.

Here is some basic code you can through in your functions.php file to add highlighting to a text string (in my case that is search term).

Obviously, in order for this to work you will need to setup a $_GET variable, probably attached to the link on your search page. That will look something like this:

You will probably want to also setup a background color for your highlight so it is, you know, highlighted:

Lastly, you can also move the user to the first instance of this search term like so:

Add Custom Fields to Woo Variations

Sometimes each variation needs its own custom fields. Say if you need to add a unique UPC or EAN code. This turned out to be surprisingly simple. Thanks to Remi Corson for the code.

PS. You should check out Remi’s page for pretty much ANYTHING Woocommerce related. It is basically an infinite well of Woo knowledge.

Taxonomy Description WYSIWYG

On sites where we are using custom post type taxonomies, we often want to have archive page. The problem, is the description field for a taxonomy is a simple textarea field. WE WANT MORE! Here is the code needed to replace the “Description” textarea field with a WYSIWYG field.

This was stolen verbatim from qwerty qwerty over on WordPress StackExchange.