It's been about a week since my last addition to the phpBay extended manual. My intention was to post a new piece of the manual each day until completion, but you know how things go. I've been quite busy. And, well, I'm going a bit out of order as well. I was going to write about phpBay keyword tracking, and I still will, just not today. I'll get to it soon enough.
This post covers inserting phpBay code into theme files. I came up with a cool idea for using it and thought I'd share it. I have a couple blogs that are 99% hands off, and have automated content, and I wanted a way to insert some auctions to the end of the posts without having to do it manually. Doing it this way you will end up with exactly the same auctions at the end of each post, which won't be as targeted, but it's still proven to work.
You could add some extra php code to show different auctions based on the current category, but I won't get into that here. If I get enough requests in the comments I'll edit this post.
This will be handy if you have an auto-blog on one main topic. I'm sure you can think of some other applications for it, this is just one purpose.
Look through the table of contents below if you want to jump to a different section first. Below the TOC are the quick steps to add phpBay code to your theme files.
Table Of Contents
- Introduction
- Installation/Activation
- Configuration
- Testing
- Per-Post/Per-Page Settings
- Geo-Targeting
- Making The Images Clickable
- Replacing WordPress Search With eBay Search
- Inserting phpBay Code Into Theme Files
- Buy phpBay Pro (20% off coupon: DA9CD69F42)
- From Picking A Market To Building/Managing Your phpBay (Or BANS) Site
Remember, phpBay has a sidebar widget you can use, but if you want more control, and want to add auction listings to the bottom of all posts, follow these steps...
- In your WordPress admin panel, go to Appearance -> Editor.
- On the right side you should see a file called Single Post (single.php), click it to open up the file in the editor on the left.
- In this file there should be a command to show the post content. Look for the_content(). Just below that you can insert the phpBay code.
- You can use any and all parameters here just like you would in a post or page, the example below shows just the keyword and the number of posts.
EDIT (June 9th, 2010): Use the code below if you want to show different auctions based on Category ID or Post/Page ID...
First.. you want to get the ID, to do that for the catgeory, under the 'Posts' menu click 'Categories', hover over the category name and in the status bar (bottom of browser) you will see a URL. The URL links to a page that allows you to edit the category. Don't click it, instead just look at the end of the URL... the catgeory ID is after the 'cat_ID=' part.
It's a similar process for posts/pages. Go to 'Edit' under 'Posts' or 'Pages'. Hover over the post or page name and in the status bar at the end of the URL you'll find the ID just after the 'post=' portion.
Now.. for most themes you can use the Category ID and/or Post ID values in single.php. For pages, use page.php.
The code for showing phpBay ads for a specific category... (replace {ID} with the actual Category ID that you found using the steps above)
NOTE: I just remembered... you can also use the category name rather than the ID if you prefer.
For displaying ads for a specific post you usually just add proper phpBay code to the post add/edit screen. However if you want to show ads for a specific post but have more control of where it goes (instead of just the body of the post) then you can do that by editing the theme. Just use the code above but instead of the 'in_category' command use 'is_single'.
Related posts:














Enter your first name and email address below to receive exclusive money making tips.





November 25th, 2009 at 11:13 am
Hi, I would love to use categories as the keywords for phpbay pro. I am testing to see how much you can make with a site that is on autopilot. If you could help with this, I would be forever grateful and would consider making a donation in return for your help.
November 30th, 2009 at 12:33 pm
Hi Chantel,
You can use php code in the single.php file to check the category ID and then write phpBay code with your chosen search keyword based on the category. I’ll send you the code in a text file…
December 29th, 2009 at 11:35 pm
Ya know, this is like the only site on the net where I found out how to do this. Only trouble is, yours is an image, and my rewriting it gives an error. lol
Did you ever post the category specific content way somewhere else? Checked around, but didn’t see it.
Thanks for this!!!
December 29th, 2009 at 11:51 pm
Hi Matt,
Here’s the code…
if ( in_category( ’1′ )) {
// Insert code here for category 1
} elseif ( in_category( array( ‘cat-name’, ‘other-cat’ ) )) {
// This shows a way to do it using category names (multiple)
} else {
// any other catgeory
}
You can also do it by post using the is_single(‘post#’) command
Hope that helps…let me know if you have anymore questions…
December 30th, 2009 at 1:05 am
Thanks for the speedy reply!
Works great!
June 4th, 2010 at 7:42 pm
Hey Keith,
Just a note to say thanks. I’ve just purchased phpbay (and phpzon), and this is really going to help me!
Just wondering, as this is a little dated, does it all still apply to the latest version of phpbay, or have you got some updated methods you’d like to share ;)
Thanks, and look forward to your reply,
Mick.
PS You mention above: \You can use php code in the single.php file to check the category ID and then write phpBay code with your chosen search keyword based on the category\. Would it be possible to have a copy of this too?
Cheers.
June 9th, 2010 at 3:06 pm
Hi Mick…
Sorry for the late response.. was on vacation.. yep.. it’s still how I do things, haven’t changed the model really at all… about the code.. sure, I’ll send you a quick email with instructions.
June 9th, 2010 at 3:52 pm
@Mick: I ended up just editing this post: http://keithjameslock.com/phpbay-pro-extended-manual-inserting-phpbay-code-theme-files/ to display the necessary code for showing phpBay ads in specific categories.
June 9th, 2010 at 4:02 pm
Hi Keith,
Hope you had a great vacation, and thanks for getting back to me, appreciated.
July 4th, 2010 at 4:30 pm
Hi again Keith,
Could you tell me whether you are a phpZon user at all, and how much of: ‘phpBay Pro: The Extended Manual guide’ would apply to it if so? I’m looking at using phpZon in exactly the same way you have outlined phpBay (geo-targetting, clickable images etc.) but I’m running into problems.
Thanks for any help with this,
Mick
July 4th, 2010 at 4:56 pm
Hi Mick… I haven’t actually tried phpZon. If I had to guess I would say it would be similar but I really have no experience at all with it. If you want to explain your issue I might be able to offer some input.