Title: getting join() error with undefined $classes variable
Last modified: February 10, 2021

---

# getting join() error with undefined $classes variable

 *  Resolved [sprowt](https://wordpress.org/support/users/sprowt/)
 * (@sprowt)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/)
 * hello kind support ppl <3
 * i’m trying to replicate functionality from GeneratePress theme (as exercise in
   learning PHP, WP, theming, FUN 🙂 and getting errors.
 * `[10-Feb-2021 11:43:37 UTC] PHP Warning: join(): Invalid arguments passed in /
   app/public/wp-content/themes/wphierarchy/inc/theme-functions.php on line 25`
 * `[10-Feb-2021 11:43:37 UTC] PHP Notice: Undefined variable: classes in /app/public/
   wp-content/themes/wphierarchy/index.php on line 25`
 * here are links to gits of my replicated code:
    [https://gist.github.com/LGitHub-sprout/7d571035fd32fe75f6a0bee9a13392f3](https://gist.github.com/LGitHub-sprout/7d571035fd32fe75f6a0bee9a13392f3)
 * here are links to the GeneratePress theme functions i’m replicating:
    [https://github.com/tomusborne/generatepress/blob/e030f57d2c26991074a6868265737424dac567d0/inc/markup.php#L289](https://github.com/tomusborne/generatepress/blob/e030f57d2c26991074a6868265737424dac567d0/inc/markup.php#L289)
 * [https://github.com/tomusborne/generatepress/blob/e030f57d2c26991074a6868265737424dac567d0/inc/theme-functions.php#L407](https://github.com/tomusborne/generatepress/blob/e030f57d2c26991074a6868265737424dac567d0/inc/theme-functions.php#L407)
 * grateful for any help, please. happy to post code here if that’s better.
 * thank you!
    -  This topic was modified 5 years, 3 months ago by [sprowt](https://wordpress.org/support/users/sprowt/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgetting-join-error-with-undefined-classes-variable%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [sprowt](https://wordpress.org/support/users/sprowt/)
 * (@sprowt)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14030148)
 * forgot a link:
    [https://gist.github.com/LGitHub-sprout/467fe0db38eafeacabc44ea9cb737a0c](https://gist.github.com/LGitHub-sprout/467fe0db38eafeacabc44ea9cb737a0c)
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14032333)
 * “join(): Invalid arguments passed” means either the first arg is not a string(
   it is a string in your case) or the second is not array of strings. The second
   is the return from wphierarchy_get_element_classes(). This is likely not returning
   what we expect. var_dump the return to confirm. If it’s not as expected, work
   back into the function, examining intermediate values to zero in on where things
   went bad. Basic debugging techniques.
 * “Undefined variable: classes” means you tried to use `$classes` without first
   assigning a value to it. I don’t see any source code for index.php, so I cannot
   speculate further.
 *  Thread Starter [sprowt](https://wordpress.org/support/users/sprowt/)
 * (@sprowt)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14032572)
 * thanks for your time, BC.
 * here’s my theme repo:
    [https://github.com/LGitHub-sprout/wordpress/tree/main/wphierarchy/app/public/wp-content/themes/wphierarchy](https://github.com/LGitHub-sprout/wordpress/tree/main/wphierarchy/app/public/wp-content/themes/wphierarchy)
 * there’s not much in it except the functionality i’m having trouble with, so there’s
   not a lot of digging involved 🙂
 * i get null on `var_dump( $classes );`
 * `/app/public/wp-content/themes/wphierarchy/index.php:26:null`
 * i’m assuming the invalid join args is because $classes is null, and therefore
   neither a string nor an array of strings.
 * however, it is assigned in markup.php on line 30:
 *     ```
       if ( ! function_exists( 'wphierarchy_create_header_classes' ) ) {
         add_filter( 'wphierarchy_create_header_class',
                     'wphierarchy_create_header_classes' );
       /**
       * Adds custom classes to the header.
       */
       function wphierarchy_create_header_classes( $classes ) {
         $classes[] = 'site-header';
       }
         return $classes;
       }
       ```
   
 * other than that there’s not much to work back to.
 * what am i missing?? i’m stumped. unless this functionality is hooked into some
   other code in the the GP theme i’m not seeing/including.
 * thanks so much for your help!
 *  Thread Starter [sprowt](https://wordpress.org/support/users/sprowt/)
 * (@sprowt)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14033022)
 * i should also mention that i do get `class=""` in the html elements i use function
   but the actual specific class isn’t output.
    -  This reply was modified 5 years, 3 months ago by [sprowt](https://wordpress.org/support/users/sprowt/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14042225)
 * `return $classes;` is outside of the function declaration 😉 The function thus
   never returns the value that it assigns.
 *  Thread Starter [sprowt](https://wordpress.org/support/users/sprowt/)
 * (@sprowt)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14046158)
 * that’s it, thank you!
 * after seeing it done in GP theme, i also cleared the `join()` error by passing
   the `$classes` arg twice as tom does in his footer.php.
 * a little digging paid off on that one.
 * as always, BC… i SO APPRECIATE your help and am really having fun with wordpress
   and php, thanks to you.
 * have a great weekend <3

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘getting join() error with undefined $classes variable’ is closed to new
replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [join](https://wordpress.org/support/topic-tag/join/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [undefined error](https://wordpress.org/support/topic-tag/undefined-error/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 6 replies
 * 2 participants
 * Last reply from: [sprowt](https://wordpress.org/support/users/sprowt/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/getting-join-error-with-undefined-classes-variable/#post-14046158)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
