studiopress / genesis-sample

This is the sample theme created for the Genesis Framework.
https://demo.studiopress.com/genesis-sample/
528 stars 284 forks source link

the woocommerce body_class() issues in my wesbite #328

Closed ajithkumar072 closed 4 years ago

ajithkumar072 commented 4 years ago

Describe the bug

Fatal error: Uncaught TypeError: Argument 1 passed to genesis_custom_body_class() must be of the type array, null given, called in wp-includes/class-wp-hook.php on line 290 and defined in wp-content/themes/genesis/lib/structure/layout.php:55 Stack trace: #0 wp-includes/class-wp-hook.php(290): genesis_custom_body_class(NULL) #1 wp-includes/plugin.php(206): WP_Hook->apply_filters(NULL, Array) #2 wp-includes/post-template.php(832): apply_filters('body_class', Array, Array) #3 wp-content/themes/genesis/lib/functions/markup.php(316): get_body_class() #4 wp-includes/class-wp-hook.php(290): genesis_attributes_body(Array) #5 wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array) #6 wp-content/themes/genesis/lib/functions/markup.php(211): apply_filters('genesis_attr_bo...', Array, in wp-content/themes/genesis/lib/structure/layout.php on line 55

To reproduce Steps to reproduce the behavior:

Expected behavior

Screenshots

System information (please complete)

Additional context

nickcernis commented 4 years ago

Hi, @ajithkumar072.

This error could occur if WordPress body classes are filtered incorrectly via custom code or a plugin.

You can try deactivating plugins and checking that custom body_class filter functions return an array in any custom code the theme contains.

Here's an example of a body class filter from Genesis Sample that correctly returns an array:

add_filter( 'body_class', 'genesis_sample_landing_body_class' );
/**
 * Adds landing page body class.
 *
 * @since 1.0.0
 *
 * @param array $classes Original body classes.
 * @return array Modified body classes.
 */
function genesis_sample_landing_body_class( $classes ) {

    $classes[] = 'landing-page';
    return $classes;

}

If you are not using custom code and your theme is unmodified, please share full steps to reproduce the error you shared so that we can investigate further.

ajithkumar072 commented 4 years ago

I have removed all the plugin but the body class was not displaying only showing class="has-no-blocks customize-support"

nickcernis commented 4 years ago

@ajithkumar072 If you have not modified the theme and are seeing the fatal error above with no plugins active, I recommend contacting the theme developer for support: https://www.mountmoriahinfotechs.com/contact/

If you are the theme developer, check the theme code to ensure that all body_class filter callback functions returns an array.

I wasn't able to reproduce the error with a fresh copy of Genesis Sample. I'm closing this for that reason, but please attach reproduction steps if this is specific to Genesis Sample and can be reproduced with unmodified code and no plugins.