• Theme: Current updated 2013 Theme
    WordPress: 4.4 the newest
    PHP: I assume since I updated to the newest WP it is also updated to the newest PHP
    Hosting: Local host on computer using XAMPP.

    Error: Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /Applications/XAMPP/xamppfiles/apps/wordpress/htdocs/wp-content/themes/twentythirteenChild/functions.php on line 578

    Code is placed in functions.php. Not sure I am getting this error message. My function looks correct but it throws out the above error. When I remove this code functions.php works fine.
    I don’t think my code is a problem (or maybe it is?) so I am hoping a second set of eyes or some suggestions would help solve this error.

    Code

    <?php
    function register_my_menus() {  //line 578
    	register_nav_menus (
    		array(
    			'footer-menu' => __('Footer Menu')
    			)
    		);
    }
    add_action('init', 'register_my_menus');
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @pcosta88,
    Your codes look fine and it is working well for me in WordPress 4.4.
    Please try changing the theme and us the above code in that theme.
    Thanks!

    Dion

    (@diondesigns)

    I’ll bet if you get rid of the <?php at the start, and the ?> at the end, the code will work perfectly. ?? Here’s a cleaned-up version of your code:

    function register_my_menus() {
    	register_nav_menus(array(
    		'footer-menu' => __('Footer Menu'),
    	));
    }
    add_action('init', 'register_my_menus');
    Thread Starter Pcosta88

    (@pcosta88)

    Super weird,

    I cut out the code that was bothersome, saved the functions.php, then put the code back in, saved it, restarted my XAMPP…and the error message went away.

    ˉ\_(ツ)_/ˉ

    Thanks for all the suggestions!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Parse error: syntax error, unexpected 'function' (T_FUNCTION)’ is closed to new replies.