Support » Theme: Customizr » Parse error: syntax error, unexpected '' ' (T_ENCAPSED_AND_WHITESPACE)

  • Hello,

    I wanted to add a footer to the Customizr child theme. I found this code on the theme website:

    Adding extra menus to Customizr

    add_action( 'init', 'register_secondary_menu' );
    function register_secondary_menu() {
        if ( function_exists( 'register_nav_menu' ) ) {
            register_nav_menu( 'secondary-menu', 'Secondary Menu' );
        }
    }
    
    add_action('wp_footer', 'display_secondary_menu', 1000, 0);   
    
    // display function for your menu:
    function display_secondary_menu() {
        echo ( has_nav_menu( 'secondary-menu' ) ? wp_nav_menu (
            array (
                'theme_location' => 'secondary-menu',
                'container_id'    => 'secondary-menu',
                'container_class'    => 'secondary-menu'
            )
        ).'

    When I tried this, I got the message:

    Parse error: syntax error, unexpected '' ' (T_ENCAPSED_AND_WHITESPACE) in /home/content/p3pnexwpnas14_data01/50/3062550/html/wp-content/themes/child-theme/functions.php on line 25

    (the code wasn’t even 25 lines long, so I am not sure why it says the error is on line 25).
    After trying to change things and having no success, I erased the code that I had entered, and pressed save, expecting it to be back to normal. Now I get the same message above^ when I try to do anything at all. I can’t open any pages or even get to the editor.

    Here is the site: http://fa8.790.myftpupload.com/

    What can I do??!
    Thank you!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Do you have FTP access? Then go to /wp-content/themes/ and delete the child theme (hope you have it saved somewhere?).

    That will get you back in to the backend as the Theme will be broken. Appearance>Themes> will let you select the Core Theme Customizr.

    Then fix the Child Theme. Suggest you go back to a clean functions.php.

    Hi,
    There is more to that code snippet. For some reason, it is broken into two parts on the page. Here is the entire code. Copy and paste this instead of what you pasted earlier.

    add_action( 'init', 'register_secondary_menu' ); // this registers your menu with WP
    function register_secondary_menu() {
        if ( function_exists( 'register_nav_menu' ) ) {
            register_nav_menu( 'secondary-menu', 'Secondary Menu' );
        }
    }
    
    // Select the add_action you need, depending on where you want to add the menu and disable the rest:
    add_action('__before_header', 'display_secondary_menu');     // use this line to add above header
    add_action('__header', 'display_secondary_menu', 1000, 0);     // use this to add after header
    add_action('__before_footer', 'display_secondary_menu');     // use this line to add above footer
    add_action('wp_footer', 'display_secondary_menu', 1000, 0);     // use this to add before credits
    
    // display function for your menu:
    function display_secondary_menu() {
        echo ( has_nav_menu( 'secondary-menu' ) ? wp_nav_menu (
            array (
                'theme_location' => 'secondary-menu',
                'container_id'    => 'secondary-menu',
                'container_class'    => 'secondary-menu'
            )
        ).'' : '' );
    }

    Do notice the penultimate line of the code.

    ).'' : '' );

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