• I’ve recently come back to WordPress theme development but am a bit of a PHP noob. Thanks in advance for the community support 🙂

    I’m building a custom theme, trying to follow the Codex instructions to enable menu functionality (I have no menu link under ‘Appearance’ in the admin area):Codex

    With the following code added in functions.php, a menu correctly shows up where the location is added in the template (but no ‘Menu’ link in the admin area under ‘Appearance’):

    function register_my_menus() {
      register_nav_menus(
        array('header-menu' => __( 'Header Menu' ) )
      );
    }

    The following code in functions.php (line 8):
    add_action( 'init', 'register_my_menus' );

    Displays an error:
    Screenshot

    Any ideas?

    Again, sorry for my PHP ignorance. Are there any recommended programming/PHP learning resources for relative beginners, preferably specific to WordPress? (e.g. how to set up a development environment and check error logs, tutorial examples, etc.)

Viewing 1 replies (of 1 total)
  • Thread Starter cmuld3r

    (@cmuld3r)

    Found the issue.

    Just read Theme Development:

    A theme can optionally use a functions file, which resides in the theme subdirectory and is named functions.php. This file basically acts like a plugin, and if it is present in the theme you are using, it is automatically loaded during WordPress initialization (both for admin pages and external pages).

    I won’t be editing any more core files. I added a functions.php with the code in my theme directory and I’m good to go 🙂

Viewing 1 replies (of 1 total)

The topic ‘Enable menu in custom template – PHP error’ is closed to new replies.