mjmfxmike on "body_class giving php error caused by invalid parameters for join()"

May 6, 2011

I’m getting an error from /wp-includes/post-template.php:

Warning: join() [function.join]: Invalid arguments passed in C:\xampp\htdocs\wordpress\wp-includes\post-template.php on line 390
class=”">

As you can see it echos the class attribute correctly, but doesn’t echo any of the classes that it should add based on whatever page/article/category etc that you’re on.

Here’s the line of php code causing the error (line 390 on post-template.php):

function body_class( $class = '' ) {
	echo 'class="' . join( " ", get_body_class( $class ) ) . '"';
}

It provides join() with ” ” for glue, and what should be an array of class names returned by get_body_class() for peices, but I’m assuming that function isn’t working properly, or something else is going wrong. I don’t think its user error on my part because I’m echoing body_class() exactly the same as is documented for that function.

<body <?php body_class(); ?>>

http://codex.wordpress.org/Function_Reference/body_class
http://codex.wordpress.org/Function_Reference/get_body_class

get_body_class() is on line 401 of post-template.php.

I tried providing body_class() with a NULL parameter since that is supposed to be the default, and I noticed in the function that it’s default is an empty string, and I wasn’t sure if NULL == ”. But, to no avail.

I also tried echoing get_body_class(), but that didn’t echo anything.

Anyone have a fix?

Leave a Comment

Previous post:

Next post: