I need urgent help figuring this out please – I’ve been working on a WordPress theme locally without problems, and now that I’ve uploaded it to the live server I’m getting this error:

Warning: Invalid argument supplied for foreach() in
/homepages/42/d357924500/htdocs/wp-includes/post.php
on line 1011

The corresponding code is related to the register_post_type function:

foreach ( $args->taxonomies as $taxonomy ) {
        register_taxonomy_for_object_type( $taxonomy, $post_type );
    }

Could this be because of an error in my register_post_type or register_taxonomy code? The error shows both on the front-end and the admin side (also displays in widget option boxes when I try to update widgets – the changes don’t save).

I don’t really know much about PHP yet (still learning), but I know just enough to manage a few WordPress customisations. Both WordPress installations use version 3.1. Any help on this issue is very appreciated.

— UPDATE —

I tried creating a new term for my custom taxonomy of “type”, and I got this error in a red error box:

**Warning: Invalid argument supplied for foreach() in
/homepages/42/d357924500/htdocs/wp-includes/post.php
on line 1011

Warning: Cannot modify header information – headers already sent by
(output started at
/homepages/42/d357924500/htdocs/wp-includes/post.php:1011)
in
/homepages/42/d357924500/htdocs/wp-includes/class-wp-ajax-response.php
on line 129

Administration

administration0]]>Administration

administration0]]>**

The taxonomy term was obviously not saved.

4 Answers
4

Ran into the same issue. @Patriek is correct. The ‘taxonomies’ argument must be an array, hence the plural. E.g.

$args = array( 'taxonomies' => array( 'myTaxonomy' ) );

This corrects the error.

I only noticed this when moving a site to another server which leads me to think the register_post_type() function requires some php settings not enabled on the remote host. register_globals is enabled… any ideas what make this issue server dependent?

Leave a Reply

Your email address will not be published. Required fields are marked *