Remove / Defer jQuery

If you use the WordPress built in jQuery you might have noticed taking some hits on your pagespeed. Here are a couple functions to increase your pagespeed score while still keeping jQuery usable.


Download and Update Post Content Images

Sometimes we have clients who have a lot of old blog posts. Often these blog posts have a lot of images in the content. Sometimes they are uploaded locally…sometimes they are not. I actually think serving images from 3rd parties is a great idea to offload the cost to your servers, but sometimes clients will request that we update their blogs so all the images are being served from their site.

Here is a quick script I wrote to do just that.

Good luck!

Highlight a search term and show its location in the excerpt

Sometimes a client will want the search term in the results page to show the first occurrence of the searched word in the content of that page. Here is some basic functionality to do that.


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!