Jaguar PC
Advertise Here

Using PhpBay to Cure 404′d A2P Posts

Posted by admin | Tips | Sunday 4 October 2009 11:24 pm

If you don’t use Phpbay or Auction 2 Post, you probably aren’t very interested in this post. Why are you still reading? What the heck is the matter with you?

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.

The Method
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.

4 Comments »

  1. Comment by Emile Bourquin — October 23, 2009 @ 10:49 pm

    In looking to implement this solution, I stumbled across another one that is already implemented in the Auction2Post version of the PremiumNews theme, and does not require phpBay.

    The Auction2Post version of the PremiumNews theme’s 404 page makes use of a function named “smart404_loop”, which, with a quick Google search, was found to be from the Smart 404 plugin(http://wordpress.org/extend/plugins/smart-404/)

    After installing and activating this free plugin and going to a url that does not exist, I was presented with a pretty good list of pages on my site that contain terms from the 404 url. I’m thinking this works best (or only) if your permalink structure is set to /%postname%/ .

    Again, look to the A2P PremiumNews 404 page to see a good implementation of how to show the pages that Smart 404 returns, as the examples given in the Smart 404 plugin are pretty weak.

    I didn’t mean to c**k-block your affiliate link to phpBay. I own phpBay myself, and any reader that has Auction2Post should absolutely own phpBay, and buy it through the link above. If you don’t own phpBay, you are leaving money on the table.

  2. Comment by Emile Bourquin — October 23, 2009 @ 11:34 pm

    I dug in a bit more, and find that your phpBay solution to 404 pages is definitely superior, as long as there is a referrer, and thus, keywords to key the phpBay search off of.

    In the case where someone comes to the site from a broken link on another site, and not from a search engine, I defer to the Smart 404 code, like so:

    if(!empty($keywords)) {PHPBAY STUFF HERE}
    else{SMART 404 STUFF HERE}

    Keep up the great work, your posts are always incredibly informative.

  3. Comment by admin — October 24, 2009 @ 12:25 am

    First of all, thanks for the detailed and insightful comment. I really appreciate it!

    Yes I’ve heard of the Smart 404 solution (as you can see I linked to that plugin in this post, but didn’t really go into any detail about it). The reason I prefer the phpbay solution on some sites is that I have some that are only updating 1-2 auctions per day, and since most of them expire within 7 days (and are auto-deleted), there isn’t a ton of content on those sites at any given time, so the chances of a post matching a visitors search query aren’t all that good (depending on the broadness of the niche), and using phpbay is a good way to ensure the visitor finds what they’re looking for.

    And don’t worry, I don’t consider it a cock-block! Haha. Thanks for reading.

  4. Comment by Emile Bourquin — October 24, 2009 @ 12:40 am

    Sorry I missed the link to Smart 404, I missed it in my haste to understand what you had done, and get it implemented!

    Good point about particular sites that have few, quickly expiring auctions. It seems that each site’s individual characteristics need to be addressed before coming up with a 404 solution for it.

    Thanks again.

RSS feed for comments on this post. TrackBack URI

Leave a dang comment