On another Wordpress blog that I have (on which I post a log more regularly than I do on this one…), I have been having trouble every time I have upgraded Wordpress lately. After the upgrade, I get an error that looks like this:

Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /xxx/webroot/wp-includes/category-template.php on line 176

It turns out that this is caused by the theme that I am using not setting categories correctly due to using functions that have been deprecated in recent versions of Wordpress. Basically, no category is set on the home page, resulting an error when the Wordpress code tries to look up the category name on the home page.

You can fix this by getting a new version of your theme if there is one available, or if there is no new version then change to a different theme. However, if you are particularly attached to your current theme and there is no new version of it (which is the situation in which I find myself) then this error is actually quite easy to fix by editing category-template.php:

Go to line 176, which looks like this:
if(array_key_exists($category, $categories))

and replace it with this:
if(!(false === $category) && array_key_exists($category, $categories))

This checks for the existence of the category variable before attempting to use it. Of course, you will need to do this every time you upgrade as when you upgrade, the new category-template.php will overwrite the one that you have edited. And the line number might change too, but the error message will tell you that.

And don’t forget to make a backup of your original category-template.php just in case the editing goes awry.

Good luck!

15 Responses to “Category Errors when Upgrading Wordpress”

  1. Derosa says:

    Skoro eto sluchitsya

  2. Nga says:

    rano ne pozdno

  3. Ferasa says:

    press releases

  4. Nga says:

    vim to very

  5. jorg says:

    At last it happens!

  6. Sasha says:

    Excellent news

  7. Новости высоких технологий says:

    hi-tech новости

    мобильные интернет-устройства трудно было назвать самой дешевой вещью в мире Читать дальше

  8. Новости хайтек says:

    новости hi-tech

    мобильные интернет-устройства трудно было назвать самой дешевой вещью в мире Читать дальше

  9. Gage says:

    Вино пробуждает экстремальные чувства…

    Попробуйтепо-казахски чай! Вкусно…

  10. Beaumont says:

    зеленый чай…

    Даже не думал что можно сварить очень полезый владимирский сбитень

  11. DARRELL says:


    Pillspot.org. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. Low price drugs. Buy drugs online

    Buy:Amoxicillin.Ventolin.Nymphomax.Aricept.Prozac.Acomplia.Wellbutrin SR.Zocor.Lipitor.Advair.Zetia.Benicar.Lasix.Female Cialis.Seroquel.Cozaar.Female Pink Viagra.SleepWell.Lipothin.Buspar….

  12. GUY says:


    Medicamentspot.com. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. Low price drugs. Order drugs online

    Buy:Cialis Professional.Propecia.Viagra Professional.VPXL.Viagra.Cialis.Cialis Super Active+.Viagra Soft Tabs.Cialis Soft Tabs.Viagra Super Force.Zithromax.Tramadol.Viagra Super Active+.Levitra.Maxaman.Soma.Super Active ED Pack….

  13. guide says:

    guide http://xmikeno6eta.AUTOPARTSVILLE.INFO/tag/guide+webkinz+shop/ : guide…

    webkinz…

  14. JOSHUA says:


    CheapTabletsOnline.Com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription pills. Order pills online

    Buy:Zocor.Ventolin.Nymphomax.Zetia.Acomplia.Female Pink Viagra.SleepWell.Lipothin.Female Cialis.Cozaar.Benicar.Advair.Aricept.Lasix.Prozac.Amoxicillin.Buspar.Lipitor.Wellbutrin SR.Seroquel….

  15. NICHOLAS says:


    CheapTabletsOnline.Com. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. High quality pills. Order pills online

    Buy:Mega Hoodia.Lumigan.Zovirax.Accutane.Zyban.Prednisolone.Valtrex.Retin-A.Petcam (Metacam) Oral Suspension.100% Pure Okinawan Coral Calcium.Actos.Arimidex.Synthroid.Nexium.Prevacid.Human Growth Hormone….

Leave a Reply

You must be logged in to post a comment. Login »