Search Exclude HTML Tags WordPress Plugin

December 4, 2011 1:43 PM by Ann

One of my clients, Jonathan at FinePrint, emailed me last week about the search function of his WordPress-based site being broken. He noted that searching for the keyword “title” on his support forum was returning almost everything. After a few tests on his site and some others, I realized that the search for “title” was actually returning all posts with images because of the title attribute in the image tags. So the real issue was that the WordPress built-in search considers HTML tags in post content to be searchable content… and that this meant that all WordPress sites were similarly “broken”.

I ended up implementing a fix for FinePrint by employing a MySQL function fnStripTags (found all over the internet and attributed to Robert Davis) to strip the HTML tags, and telling WordPress to use it by hooking into the posts_search filter.

From what I’ve been able to find, this “bug” has been around for years so perhaps it’s simply not an issue that people really care about or they just consider it intended functionality. Although I’m actually surprised to find very little in the way of complaints… or maybe I haven’t looked hard enough. Anyway, since it makes a lot more sense to me that HTML tags be stripped, I’ve taken the time to bundle this fix up into a plugin and get it onto WordPress.org. To apply on your site, just download, install, and activate!

Download the plugin “Search Exclude HTML Tags” from WordPress.org.

Sticky Custom Post Types WordPress Plugin

August 20, 2011 5:47 PM by Ann

I needed sticky custom post types for a client project but found out that WordPress doesn’t support this out of the box. Luckily it turned out to be pretty simple to add in that functionality with just a little bit of code… which I have turned into a plugin for everyone to use! YAY!

Installation/instructions:

1. Download the plugin from wordpress.org.

2. Upload sticky-custom-post-types.php to the /wp-content/plugins/ directory.

3. Select custom post types you want to enable with the sticky function on the ‘Settings → Reading’ page. Unless you’re using custom queries to display your sticky posts, you probably also want to check the option to display selected post types on the blog home.

4. When adding/editing a custom post type, check the “Stick this to the front page” checkbox if you want to stick that custom post to the front page.

And that’s it!

Unfortunately there’s no way to put the “Stick this…” checkbox in the same place as it is on the built-in “Posts” add/edit page (to do so would require modifying core code), but I think that having it display immediately is actually a lot more straightforward than having to click through the visibility setting edit link to get to it.

How to remove the Media Library tab in the WordPress media uploader

October 8, 2010 12:09 PM by Ann

By default, WordPress allows a user with the “upload_files” capability to view all items in the media library. Here’s how to remove the Media Library tab in the WordPress media uploader completely (e.g. for contributors without the “edit_others_posts” capability).

Copy and paste the following code into a plugin or the theme functions.php file:


function remove_medialibrary_tab($tabs) {
  unset($tabs['library']);
  return $tabs;
}
if(!current_user_can('edit_others_posts'))
  add_filter('media_upload_tabs','remove_medialibrary_tab');

WordPress Automatic Links plugin

March 4, 2009 10:58 PM by Ann

Here’s a super simple WordPress plugin that automatically adds HTML anchor tags to plain text links and email addresses embedded in the content of posts and pages (WordPress already does this by default for comments). It also gives you the option to set the nofollow attribute value on all automatically generated hyperlinks.

Download this plugin at WordPress.org.

WordPress 2.6 / 2.7 + bbPress 0.9 cookie integration plugin

February 26, 2009 12:01 AM by Ann

This plugin is for WordPress 2.6 or 2.7. It enables WordPress to generate cookies that work with bbPress 0.9 so that single sign-on can be accomplished between the two. Follow the usual integration instructions and enable this plugin in your WordPress installation. I also advise clearing your cookies.

The integration is all up and running on my site at BayAnime.com. I’d like to add that I was able to put the plugin together without writing a single line of code! It’s literally all the necessary functions cut and pasted directly from WordPress 2.5.1 pluggable.php, so kudos to WordPress for making it easy!

Download this plugin at WordPress.org.

When you do cookie integration please keep in mind that there are some login hooks in pluggable that might not be called in either WP or bbPress depending on which side your user logged in from. This might affect the functionality of some plugins.

For example, after rerouting all my bbPress logins to WP I realized that the ‘bb_set_current_user’ action hook on a bbPress plugin I used was no longer being called, so I had to incorporate it in on the WP side using the ‘set_current_user’ hook.

bbPress 1.0 users should use this plugin instead.

WordPress Plugin: Separate Feed Comments and Trackbacks

October 2, 2008 11:40 PM by Ann

I couldn’t find anything out there that separated comments and trackbacks from the sitewide and post comments feeds in WordPress, so I had to take a peek at the source to figure this one out. Luckily there’s an (undocumented) hook “comment_feed_where” that makes it easy! Woo!

Anyway, here’s the plugin in case anyone else might be interested…

Download this plugin at WordPress.org.