cjones
cjones

Reputation: 377

Custom theme build - can't add menu functions.php

Trying to follow a tutorial, setting up a Wordpress theme from scratch and can't get the menu option to show.

functions.php

<?php
function appdevwp_theme_styles() {
    //featured theme support
    add_theme_support( 'post-thumbnails' );
    //Menu
    register_nav_menus( array( 
        'primary' => __('Primary menu'), 
        'secondary' => __('Secondary menu') 
      ) );
}
?>

If any one can see where I'm going wrong, please share, because every site I've been on suggests that the above example is correct, yet the option still doesn't become available.

Upvotes: 0

Views: 38

Answers (2)

cjones
cjones

Reputation: 377

Thanks Alex,

Seems the original post version seems to run ok watching the tutorial, but your way actually works...

<?php

    //featured theme support
    add_theme_support( 'post-thumbnails' );
    //Menu
    register_nav_menus( array( 
        'primary'  => __('Primary menu'), 
        'secondary'  => __('Secondary menu') 
      ) );

?>

Upvotes: 0

Alex
Alex

Reputation: 2775

You run add_theme_support and register_nav_menus functions inside appdevwp_theme_styles however you do not call appdevwp_theme_styles function. So you have 2 ways:

  1. Run your function after initializing. Just add appdevwp_theme_styles(); line at the end.
  2. Run add_theme_support and register_nav_menus outside of your new function. Just remove this wrapper function appdevwp_theme_styles() {....}.

Upvotes: 1

Related Questions