To be perfectly honest, I’m a little bit buzzed right now, but I will try to stay on topic.
If you’re not already familiar, Auction 2 Post is a very handy WordPress plugin that feeds ebay auctions into your wordpress blogs as posts to provide you with all sorts of fresh content. However, once those auctions end, you don’t really want a bunch of posts linking to dead auctions. Ebay doesn’t want you doing that, either. Luckily, A2P has the ability to automatically delete posts for you once those items expire.
But what about the pages on your site that are indexed by Google and other search engines that get automatically deleted by A2P? Unless you do something about it, those precious visitors trying to access those pages will arrive on your site’s default 404 page. How you handle these 404 visitors is up to you. One plugin you might want to check out to handle your 404′s is called Smart 404. That’s one idea. But in my opinion, this is a better one…
If you’re a member of EPN and you are using Auction 2 Post, chances are you also own PhpBay. If not, well, you should probably take care of that. Click here to buy it so I can get my $19 or whatever and we can move on.
First of all, I just want to say that I suck complete ass at php and pretty much anything that takes any real coding know-how. Fortunately, Joshua Ziering aka Enigmabomb was kind enough to help me put this code together (based on some code I stole and his own magic) to get this thing to work. Please buy (or give) him a lap dance at ASW to show your appreciation.
The idea of this trick is to take the keyword your visitor used to find your site to begin with and show relevant ebay auctions based on their search query in the place of a useless 404 page. It will work with Google, Bing, Yahoo, and any search engine that uses “q=” to pass the variable.
You’re going to need to edit your theme’s 404.php file to do this. Since it is apparently impossible for a mortal man to get certain code to display properly as code in this post with the theme I am using on this blog, I am going to have to give you text files.
Here is your basic WordPress 404.php file (will likely be slightly different depending on your theme)
And here is the 404.php I use with all the magic code added to it. Obviously it will not work if you don’t have PhpBay installed on your site.
Of course you might want to tweak that a little bit in order to suit your theme, every case is different. But that should at least get you headed in the right direction.
Booyah. Big ups to Enigmabomb. Peace.