Ask me a question at the Wordpress Ninja Forum
How To Fix That Nasty Error About Headers Not Sent (yuck)
Posted on August 4, 2008
Filed Under Wordpress Solutions | Leave a Comment
You know the one - maybe you have seen it, maybe you haven’t. If you haven’t yet, then i hope you never do….It looks something similar to this:
Warning: Cannot modify header information - headers already sent by (output started at http://………….)
Nasty huh? That’s all you get on an otherwise blank page. Well, luckily it’s a really simple fix. PHP sometimes has a hissy fit at whitespace. What does that mean, you ask? Well, chances are you were editing some code and accidentally (whether you knew it or not) left a ’space’ or ‘carriage return’ where it shouldn’t be - namely after the final PHP tag i.e. ?> at the very end of the file. I have had this several times after editing the wp-config.php file in Dreamweaver.
Make sure that there are no spaces or carriage returns after that final tag - re-upload the file in question and it’s back to normal - no more ugly errors.
Related Posts:
Duplicate Sections In The Sidebar - How Did They Get There?
How To Fix Code Errors On Page
How To Force Wordpress To Give You Relevant Adsense Ads
Wordpress Ninja Forum Coming Soon
Posted on August 4, 2008
Filed Under General | 1 Comment
Hi everyone,
just wanted to say that i am working on a forum for this site where everyone can post questions and issues. I feel it’s a better way to do Q&A rather than emails back and forwards everywhere, plus other people can benefit from solutions posted. I’m hoping to have it ready by the end of the week - just need to finish sorting out some issues with the account integration.
cheers,
Paul.
Related Posts:
Duplicate Sections In The Sidebar - How Did They Get There?
Posted on August 2, 2008
Filed Under Wordpress Solutions | Leave a Comment
Had a great question from someone who had multiple ‘Categories’, ‘Recent Posts’, ‘Recent Comments’ etc. showing up in her sidebars. Upon examining her sidebar.php file (this was using a Prosense theme), there were no duplicate sections of code. This only left one explanation…Widgets!
Widgets can be great for adding things really easily, but you do lose a fair amount of control by using them. In this case she had widgets set up to display those sections in her sidebars, as well as the hard-coded sections in the sidebar.php file. This caused the duplicates.
Here’s how you fix it.
To remove those widgets, go to your WP-admin (assuming Wordpress 2.5.1 or later) area and go to Design>Widgets then make sure the left sidebar is selected (top right of screen - drop down box for sidebar - probably called ’sidebar1′). Then expand the unwanted widgets and choose ‘Remove’ for each. That’s it.

Some people love widgets, but I normally don’t use them as i can get much more control over where i put things by doing it manually - but that’s just me ![]()
Related Posts:
How To Fix That Nasty Error About Headers Not Sent (yuck)
How To Fix Code Errors On Page
How To Force Wordpress To Give You Relevant Adsense Ads
Adding Google Adsense To A New Wordpress Theme
Posted on August 1, 2008
Filed Under Guides | 3 Comments
Ok, so you downloaded a new theme that totally rocks in every single way, except one thing - there’s no pre-setup Google Adsense code
That’s where the Wordpress Ninja comes in - cue…me
Before we do anything, you need a Privacy Policy to conform to Google’s TOS. This ‘Privacy Policy Plugin‘ is great - it automatically creates it for you after just a couple of options being set for it. Wordpress Ninja highly recommends this plugin.
There are a lot of decent Google Adsense plugins available, but i thought i would show you the hard way how to insert Adsense manually so you have full control over what you are doing. Once you know the long and hard way the plugins will look like they are for Newbies!
If you do want to use a plugin for managing Google Adsense code in your blog then i can recommend this one, though there are many you can choose from. Have a search and find one that best suits your needs.
Ok, back to the manual creation…
First step - which i’ll assume you have done already - is to setup your Google Adsense account. I’m not going to go into the account setup and Ad setup as there are many great tutorials and help files on the web for this - the Google help itself is pretty decent. Some important points to remember when setting up new ads are this:
- Make sure you color-code the ads to blend in with your site. Just do a Google search for ‘optimizing adsense’ and you’ll be able to find a lot of great articles on how to go about this
- Create channels so you can track your different ad blocks’ performance
- When you create a new ad block, copy and paste the code they give you into a text editor and keep it all handy. Neatly organize them all so you know which code belongs to which type of ad block e.g. 160×600 Skyscraper - then the code underneath.
- Think about how you want to organize your ads on your blog theme e.g. do you want a large leaderboard banner across your blog page? Will it even fit? Do you want ads in the sidebar? Do you want a square ad block in each of your posts (like the classic Prosense theme)? Create the ads you will need based on your theme design. Due to the size constraints of your theme you may have to do a bit of trial and error to get the right ad units for your site.
Ok, once all the ads are created and you have saved out your code blocks, open your favorite code editing app (i listed several good ones in this post) and start editing your Wordpress files. Now, depending on your desired ad placement, you need to modify the appropriate .php files within your wp-content/themes/mytheme/ folder. For example, if you want any ads in your sidebar then you need to edit sidebar.php. Remember my previous post about the way Wordpress themes are layed out in your site, broken into parts - Header, Content Body, Sidebar(s) and Footer. This is important because it helps you to work out which file you need to edit. Here’s a quick breakdown of the key files you will need to edit that sit under your theme folder:
- Sidebar.php is for the sidebar (well, duh?) - if the sidebar is divided into left and right sections then this file will usually hold both left and right sidebar sections. They will usually be setup as CSS divisions rather than seperate files. This is where you would usually add a skyscraper style Google ad unit
- Index.php is the main content - imagine it like a framework that loads the posts and everything in the main body. This is where you might add Link Ad Units at the top - depending on where your NavMenu (if any) is located. Basically anything added here will show up on all pages.
- Single.php is very important - this file is essentially each individual post, so you would add any ad units here such as ads inside each post, or directly above or below each post. The key point is that ads in here apply to EVERY post.
So you now know which file to edit. I’m going to use an example of a sidebar ad unit (a long skyscraper), so i start editing sidebar.php in my code editor. I want to place the ads in the left section of my sidebar under my pages list, so i find the code section that contains something like <div id=”left_sidebar”> or something like that. Then i find the code that contains “WP_list_pages” which is our page list - this is probably enclosed in <div> tags or <ul> or something similar. We want the Google Ad code to appear under the page list so we copy our Google Ad skyscraper code from the text editor we saved it to earlier and paste it into our sidebar.php file at this section. You dont have to enclose the Google Ad code in any tags, but i generally chuck inside a <div></div> tag just to keep it all looking nice.
That’s basically it. Save your changes and upload to the your server, overwriting the original (you did take a backup of your server file first, right? Always take a backup just in case you need to revert back).
Also remember that when you create a new Google ad unit it can take 15mins or so to become active - until this time it will be blank - dont freak out though - they should turn up shortly. Allow some time also once it is active before the ads become relevant. If they are still irrelevant after a day or so then check out my post on forcing relevant Google Adsense ads in your Wordpress Blog.
So i know this article has been rather generalized, but hopefully you got something out of it. As always feel free to ask me any questions.
Related Posts:
Setting Up RSS Feeds With Wordpress
Wordpress - A Beginners Guide Part 3 - “Choosing Themes And Plugins”
Wordpress - A Beginners Guide Part 2 - “Wordpress Installation And Setup”
Does This Site Need A Forum?
Posted on August 1, 2008
Filed Under General | 2 Comments
Hi readers,
thought i’d throw the question out there - does Wordpress Ninja need a forum? I was thinking that i could set up a forum where people could post their questions and issues and then i could answer them from there, rather than by email. I’d like to hear people’s feedback on this. There’s nothing worse than having a forum lying around that no-one uses
So if i get a decent response on this then i will set one up, otherwise stick to the same method of helping out by email then posting the best issues on the main blog.
Related Posts:
How To Fix Code Errors On Page
Posted on August 1, 2008
Filed Under Wordpress Solutions | Leave a Comment
I’ve received a few issues from people whose sites display fine, but at the top it has some error message such as this example:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /xxxxx…./xxxxxx/url/blog/wp-includes/widgets.php on line 60
Note the URL address given. Believe it or not, this error is actually very descriptive and tells us all we need to know. First up, any problem with any file in the /wp-includes/ folder should not happen unless one of those core files is modified somehow. So for the record, let me reiterate that these files should not ever need to be touched - they are Wordpress core code files that are essential to the functioning of the site and are not to be edited by anyone.
So if they have been modified or corrupted as has this example above (widgets.php) all you need to do is to replace the existing (corrupted) file with the original one from the Wordpress install files. If you are using Wordpress version 2.5.1 for example, download the install files from here and extract it to your desktop. Find that same file (in this example was /wp-includes/widgets.php) and upload it to your server into the same path - overwriting the existing (corrupted) file.
One final note - you should not actually ever have to modify any file outside of your theme folder e.g. /wp-content/themes/mytheme/ as these will be core Wordpress files.
That should do the trick. As always, if you still are stuck you can send me the file and i’ll take a look at it.
Related Posts:
Wordpress Theme Customizations - Removing The Sidebar Altogether
Why Do Wordpress Themes Sometimes Not Display Properly?
Duplicate Sections In The Sidebar - How Did They Get There?
Live Chat With Wordpress
Posted on July 27, 2008
Filed Under General | 3 Comments
I have received a few queries about Wordpress Plugins, in particular a Live Chat plugin. I have found this one to be very good, in fact i have implemented it on this site - see the Live Chat tab on the navigation menu at the top of my page. Note, i have temporarily disabled the Live Chat so i can post the exact code here in this guide, otherwise it would appear instead of the code snippet, making the guide useless.
The plugin i am talking about is called WP-Live-Chat and can be downloaded free from here. It basically allows you to set up an IRC channel and embed it in your page on your blog, so any users can chat live to each other via that channel. It is especially good ifyou have decent traffic and a strong community where people may want to discuss a lot of topics live.
It is very simple to set up, but you must ensure your hosting server supports Javascript - if your hosts block script execution then it will likely fail to run properly. You should email your host’s customer support to check this out.
Once you confirm Javascript is ok to run on your server, upload the plugin zip to your /plugins folder and extract it. In your WP-Admin panel go to the Plugins tab and activate the plugin. Once activated, create a new Page (or a new Post if you prefer) and enter any lead in text you need.
One thing to also consider before the next step is what image you want for the chat ’splash’ graphics. If you want a custom image then you need to upload that image to your server before going on to the next step. Dont make the image too big or it may ruin your layout or get cut off in places. This may take some experimenting to get it the right size.
So the final step is to enter the following example code (modified to fit your site of course) on the page under ‘Visual’ editing mode.
[livechat:WPninja:skin:default:image:http://example.com/x.jpg:close]
Just to explain this code, the ‘WPninja’ parameter is the channel name you wish to initiate on launch. The ’skin’ parameter can be changed (check out the author’s homepage for more info on that) though i quite like the default best. The ‘image’ parameter is the full url of the splash graphic image you want to display on the page - users will click on this image to launch the live chat app.
Well, thats all there is to it, so try it out - let me know if you have any trouble or questions and i’ll be glad to assist.
Related Posts:
My Work
Make Contact
Welcome to Wordpress Ninja!
How To Force Wordpress To Give You Relevant Adsense Ads
Posted on July 22, 2008
Filed Under Wordpress Solutions | 3 Comments
I struggled with this for some time, before working out that you can ‘force’ Wordpress to serve up relevant Google Adsense Ads from the get go, rather than wait several weeks for it to start serving relevant ads. By relevant i mean actually related to you site content, rather than some random unrelated garbage.
I tried everything including section targeting for the Google ads, where you tell the code where to include or exclude content for Google to use for it’s ad algorithms. No joy, it still wouldn’t serve up relevant ads. However, i should clarify this - all ads would show up relevant if i went directly to my homepage with the /index.php after it e.g. http://www.wordpressninja.com/index.php though it would be irrelevant if i just typed in http://www.wordpressninja.com to my browser.
This gave me a clue, seeing as it was related to the actual url being entered. That’s when i investigated the wp-config file and eventually worked this out.
Now i have read many posts from people around the web with the same issue but no real solution - some people said it would just fix itself after some time - maybe related to Google indexing it? But in my case it just would not serve relevant Google Adsense Ads even after 2 weeks.
Anyway, this fix worked for me, though i can’t guarantee it will work for you too as it may also depend on your hosting server’s config. In a nutshell you need to overide the home and siteurl DB settings. To do this, edit your wp-config.php file in the wordpress install root and add the following lines of code after the existing DEFINE statements at the top. This code example here is if you installed WP into a subdirectory:
define(’WP_SITEURL’, ‘http://www.sample.com/subdir’);
define(’WP_HOME’, ‘http://www.sample.com’);
Obviously you need to put your own site in there. If your WP install is not in a subdirectory then it should just be like this code example:
define(’WP_SITEURL’, ‘http://www.sample.com’);
define(’WP_HOME’, ‘http://www.sample.com’);
That’s it, after saving those changes the ads immediately become relevant for the home url http://www.xxxxxx.com, just like the /index.php url shows.
Let me know if it works for you or not.
Also, remember to back up your files and DB before doing any changes like this, just in case something breaks badly - yes, i’ve been there and it is not a nice place to be.
Related Posts:
Duplicate Sections In The Sidebar - How Did They Get There?
Adding Google Adsense To A New Wordpress Theme
How To Fix Code Errors On Page
Hi, i am the Wordpress Ninja. My name is Paul and my goal is to be able to answer everyone's Wordpress questions (for free) and post the best solutions on this blog. So for all questions and issues please post in the