• I tried adding custom menus by adding the code found at https://codex.www.ads-software.com/Navigation_Menus in a functions.php file in my child theme but on live preview it shows the code across the top, and, daring to, I activated, but that broke the install and I had to reset by removing the child via FTP. What am I doing wrong? Thanks for any help or clues.

    function register_my_menus() {
      register_nav_menus(
        array(
          'header-menu' => __( 'Header Menu' ),
          'extra-menu' => __( 'Extra Menu' )
        )
      );
    }
    add_action( 'init', 'register_my_menus' );
Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter CyberCobre

    (@cybercobre)

    Holy wow. THANK YOU @ikaring Trying it.

    Thread Starter CyberCobre

    (@cybercobre)

    @ikaring

    This is my functions.php file code now:

    What did I do wrong?

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    function twentysixteen_setup() {
    	/*
    	 * Make theme available for translation.
    	 * Translations can be filed in the /languages/ directory.
    	 * If you're building a theme based on Twenty Sixteen, use a find and replace
    	 * to change 'twentysixteen' to the name of your theme in all the template files
    	 */
    	load_theme_textdomain( 'twentysixteen', get_template_directory() . '/languages' );
    
    	// Add default posts and comments RSS feed links to head.
    	add_theme_support( 'automatic-feed-links' );
    
    	/*
    	 * Let WordPress manage the document title.
    	 * By adding theme support, we declare that this theme does not use a
    	 * hard-coded <title> tag in the document head, and expect WordPress to
    	 * provide it for us.
    	 */
    	add_theme_support( 'title-tag' );
    
    	/*
    	 * Enable support for Post Thumbnails on posts and pages.
    	 *
    	 * @link https://codex.www.ads-software.com/Function_Reference/add_theme_support#Post_Thumbnails
    	 */
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 1200, 9999 );
    
    	// This theme uses wp_nav_menu() in two locations.
    	'primary' => __( 'Primary Menu', 'twentysixteen' ),
    		'topnav'  =>  'TopNav Links Menu',
    		'footer' => 'Footer Menu',
    		'social'  => __( 'Social Links Menu', 'twentysixteen' ),
    	) );
    
    	/*
    	 * Switch default core markup for search form, comment form, and comments
    	 * to output valid HTML5.
    	 */
    	add_theme_support( 'html5', array(
    		'search-form',
    		'comment-form',
    		'comment-list',
    		'gallery',
    		'caption',
    	) );
    
    	/*
    	 * Enable support for Post Formats.
    	 *
    	 * See: https://codex.www.ads-software.com/Post_Formats
    	 */
    	add_theme_support( 'post-formats', array(
    		'aside',
    		'image',
    		'video',
    		'quote',
    		'link',
    		'gallery',
    		'status',
    		'audio',
    		'chat',
    	) );
    
    	/*
    	 * This theme styles the visual editor to resemble the theme style,
    	 * specifically font, colors, icons, and column width.
    	 */
    	add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) );
    }

    What I got was this on Live Preview and it’s still grinding away after more than 5 minutes. https://www.grimace-and-giggle.com/best-novels/wp-content/themes/grimgiggle/img/ScreenshotGG1-12-2016_835PM.jpg

    See this section.

    // This theme uses wp_nav_menu() in two locations.
    	'primary' => __( 'Primary Menu', 'twentysixteen' ),
    		'topnav'  =>  'TopNav Links Menu',
    		'footer' => 'Footer Menu',
    		'social'  => __( 'Social Links Menu', 'twentysixteen' ),
    	) );

    You seems to have deleted register_nav_menus( array(

    Thread Starter CyberCobre

    (@cybercobre)

    Ah. Okay. Hm. Working on it. Do you take donations for your help? I truly appreciate it.

    Thread Starter CyberCobre

    (@cybercobre)

    Just not working. I need to do chores so I’ve got to quit for tonight.

    Thanks for all your help so far. I’ll take this up tomorrow again, I guess. I’m exhausted and all the livestock are tree hours late for their dinners.

    Ok.
    I have found another syntax error.

    You need closing } for theme_enqueue_styles.

    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }

    Well, thanks for your proposal, but I dont take any donations here.

    Thread Starter CyberCobre

    (@cybercobre)

    @ikaring Well then contact me through Grimace-and-giggle dot com and let me throw you a bit of gratitude.

    Adding your fix to the file right now. (done with chores because I got some help).

    Thread Starter CyberCobre

    (@cybercobre)

    @ikaring Okay. The theme now comes up (and nice and fast, too) but still now added custom menus. Darn it, darn it, darn it. :S

    Here’s the present functions.php file in its entirety

    <?php
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
    function theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    }
    
    function twentysixteen_setup() {
    	/*
    	 * Make theme available for translation.
    	 * Translations can be filed in the /languages/ directory.
    	 * If you're building a theme based on Twenty Sixteen, use a find and replace
    	 * to change 'twentysixteen' to the name of your theme in all the template files
    	 */
    	load_theme_textdomain( 'twentysixteen', get_template_directory() . '/languages' );
    
    	// Add default posts and comments RSS feed links to head.
    	add_theme_support( 'automatic-feed-links' );
    
    	/*
    	 * Let WordPress manage the document title.
    	 * By adding theme support, we declare that this theme does not use a
    	 * hard-coded <title> tag in the document head, and expect WordPress to
    	 * provide it for us.
    	 */
    	add_theme_support( 'title-tag' );
    
    	/*
    	 * Enable support for Post Thumbnails on posts and pages.
    	 *
    	 * @link https://codex.www.ads-software.com/Function_Reference/add_theme_support#Post_Thumbnails
    	 */
    	add_theme_support( 'post-thumbnails' );
    	set_post_thumbnail_size( 1200, 9999 );
    
    	// This theme uses wp_nav_menu() in two locations.
    	register_nav_menus( array(
    	'primary' => __( 'Primary Menu', 'twentysixteen' ),
    		'topnav'  =>  'TopNav Links Menu',
    		'footer' => 'Footer Menu',
    		'social'  => __( 'Social Links Menu', 'twentysixteen' ),
    	) );
    
    	/*
    	 * Switch default core markup for search form, comment form, and comments
    	 * to output valid HTML5.
    	 */
    	add_theme_support( 'html5', array(
    		'search-form',
    		'comment-form',
    		'comment-list',
    		'gallery',
    		'caption',
    	) );
    
    	/*
    	 * Enable support for Post Formats.
    	 *
    	 * See: https://codex.www.ads-software.com/Post_Formats
    	 */
    	add_theme_support( 'post-formats', array(
    		'aside',
    		'image',
    		'video',
    		'quote',
    		'link',
    		'gallery',
    		'status',
    		'audio',
    		'chat',
    	) );
    
    	/*
    	 * This theme styles the visual editor to resemble the theme style,
    	 * specifically font, colors, icons, and column width.
    	 */
    	add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) );
    }

    Codes looks ok and I have tested on my site with success, with 4 theme locations at bottom of Appearance -> Menus page.

    Thread Starter CyberCobre

    (@cybercobre)

    @ikaring
    Okay. Well, um……… ?? I haven’t a clue what I’m doing wrong. So…I’m going to bed. Thanks for all your help. I’ll look at it tomorrow with fresh eyeballs.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Add Custom Menu to Twenty Sixteen?’ is closed to new replies.