Title: Syntax Errors
Last modified: May 9, 2019

---

# Syntax Errors

 *  Resolved [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/)
 * There is a syntax error in the following code:
 *     ```
       add_theme_support(
       	'amp',
       	array(
       		'nav_menu_dropdown' => array(
       			'sub_menu_button_class'        => 'dropdown-toggle',
       			'sub_menu_button_toggle_class' => 'toggled-on', // (optional)
       			'expand_text '                 => __( 'expand', 'domain' ),
       			'collapse_text'                => __( 'collapse', 'domain' ),
       		),
       	),
       );
       ```
   
 * The last comma needs removing please.
 * On the following page, you use an almost identical solution and that also needs
   the very last comma removing.
 * [https://amp-wp.org/documentation/playbooks/toggling-hamburger-menus/](https://amp-wp.org/documentation/playbooks/toggling-hamburger-menus/)
 *     ```
       add_theme_support(
       	'amp',
       	array(
       		'nav_menu_toggle'   => array(
       			'nav_container_id'           => 'site-navigation',
       			'nav_container_toggle_class' => 'toggled-on',
       			'menu_button_id'             => 'site-navigation-toggle',
       			'menu_button_toggle_class'   => 'toggled-on',
       		),
       	),
       );
       ```
   
 * Hope this helps, because I’m a non-coder, well a coding newbie to be exact, and
   for people like me these things are frustrating if you don’t know how to resolve
   them.
 * Thanks in advance.
 * David
    -  This topic was modified 6 years, 11 months ago by [David Elstob](https://wordpress.org/support/users/davwaiguy/).
      Reason: To include code tags
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsyntax-errors-7%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 12 replies - 1 through 12 (of 12 total)

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11515597)
 * Thanks for reporting! The pages have been fixed.
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11519484)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) The code works
   perfect regarding the menu, but it’s also throwing two errors in the AMP Validator
   for missing navigation tags. One for tabindex and the other for role.
 * I know how to fix them, but unsure about where to place the code.
 * Is there any chance you can point me in the right direction please?
 * [https://parallaxsite.com](https://parallaxsite.com)
 * code to be introduced:
 * `role="navigation" tabindex="0"`
 * Cheers!
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11519538)
 * [@davwaiguy](https://wordpress.org/support/users/davwaiguy/) Hey, I don’t think
   the code is quite right. It should not be targeting the `nav` to toggle the menu.
   It should rather be targeting the `menu-toggle` button. Please share the code
   you are using.
 * So you should add an `id` to this element:
 * `<button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false"
   ><span class="mobile-menu">Menu</span></button>`
 * For example, `site-navigation-toggle`:
 * `<button id="site-navigation-toggle" class="menu-toggle" aria-controls="primary-
   menu" aria-expanded="false"><span class="mobile-menu">Menu</span></button>`
 * And then you can the `menu_button_id` as shown in the example above.
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11519687)
 * Hi Weston, I used your example from AMP-WP.Org as so…
 *     ```
       add_theme_support(
       	'amp',
       	array(
       		'nav_menu_toggle'   => array(
       			'nav_container_id'           => 'site-navigation',
       			'nav_container_toggle_class' => 'toggled',
       			'menu_button_id'             => 'site-navigation',
       			'menu_button_toggle_class'   => 'toggled',
       		),
       	)
       );
       ```
   
 * Then that works fine, but shows the 2 errors I mentioned.
 * When I filled in the blanks, the errors go away in the AMP Validator, but I just
   don’t know where to place the snippets of code in the various PHP files?
 * Hope this makes sense? Thanks.
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11519703)
 * The attribute ‘role’ in tag ‘nav’ is missing or incorrect, but required by attribute‘
   on’.
 * The attribute ‘tabindex’ in tag ‘nav’ is missing or incorrect, but required by
   attribute ‘on’.
 * That’s what the errors say word for word.
 * So when I type role=”navigation” and tabindex=”0″ in the AMP Validator it goes
   away so I just presumed the code was correct, if I placed it in the appropriate
   file?
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11519815)
 * You need to add an `id` attribute to the button and use it as the value for `
   menu_button_id`.
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11520793)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) I understand
   what you are saying, but I have done that and I am using the correct button id,
   which is, ‘site-navigation’.
 * The Chrome AMP Validator extension is flagging 2 x errors, that I’ve described,
   and when I put the code snippets in that I mention the errors disappear.
 * Surely that means that I’ve added the right code, as it’s now validated?
 * My only problem is, I don’t actually know where to insert it in the filing system
   of my child theme. What I’m thinking is, if it’s the AMP plugin that’s outputting
   the code, is it even possible for me to append it?
 * This is the code that is throwing two errors.
 * `<nav id="site-navigation" class="main-navigation" itemtype="https://schema.org/
   SiteNavigationElement" itemscope [class]="&quot;main-navigation&quot; + ( navMenuToggledOn?&
   quot; toggled&quot; : '' )" on="tap:AMP.setState({ navMenuToggledOn: ! navMenuToggledOn})"
   aria-expanded="false" [aria-expanded]="navMenuToggledOn ? 'true' : 'false'">`
 * All I need to do is add these two bits I mentioned:
 * `role="navigation" tabindex="0"`
 * Then it show the green light in the Validator.
 * Thanks for your input.
    -  This reply was modified 6 years, 11 months ago by [David Elstob](https://wordpress.org/support/users/davwaiguy/).
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11520944)
 * I’ve explained what to here: [https://wordpress.org/support/topic/syntax-errors-7/#post-11519538](https://wordpress.org/support/topic/syntax-errors-7/#post-11519538)
 * Once you do that, replace:
 * `'menu_button_id' => 'site-navigation',`
 * With:
 * `'menu_button_id' => 'site-navigation-toggle',`
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11520992)
 * That’s exactly it!!! 🙂
 * Thanks very much.
 * When I right clicked on the button and selected Copy – XPath – it was only giving
   me site-navigation rather than site-navigation-toggle.
 * Anyhow, it’s all perfect now. Cheers.
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11521003)
 * [@davwaiguy](https://wordpress.org/support/users/davwaiguy/) Actually, to avoid
   having to modify the `<button>` at all, you can use `menu_button_xpath` instead
   of `menu_button_id`. So you can do this:
 *     ```
       add_theme_support(
       	'amp',
       	array(
       		'nav_menu_toggle'   => array(
       			'nav_container_id'           => 'site-navigation',
       			'nav_container_toggle_class' => 'toggled',
       			'menu_button_xpath'          => '//*[ @id = "site-navigation" ]//button[ contains( @class, "menu-toggle" ) ]',
       			'menu_button_toggle_class'   => 'toggled',
       		),
       	)
       );
       ```
   
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11521015)
 * Thanks for the heads up.
 * I’ll try that instead, because changing the ID to site-navigation-toggle, gives
   no errors, but the menu has stopped working!
 * Two minutes. I’ll try the other.
 *  Thread Starter [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * (@davwaiguy)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11521020)
 * [@westonruter](https://wordpress.org/support/users/westonruter/) the last solution
   definitely works.
 * The menu works fine. No errors in the AMP Validator.
 * Thanks once again. Appreciate you’re help!
 * Think that a mistake that I made was instead of copying the full XPath, I was
   only grabbing the name from the path. At last now I know the proper way. 🙂
    -  This reply was modified 6 years, 11 months ago by [David Elstob](https://wordpress.org/support/users/davwaiguy/).
    -  This reply was modified 6 years, 11 months ago by [David Elstob](https://wordpress.org/support/users/davwaiguy/).
    -  This reply was modified 6 years, 11 months ago by [David Elstob](https://wordpress.org/support/users/davwaiguy/).

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Syntax Errors’ is closed to new replies.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [syntax errors](https://wordpress.org/support/topic-tag/syntax-errors/)

 * 12 replies
 * 2 participants
 * Last reply from: [David Elstob](https://wordpress.org/support/users/davwaiguy/)
 * Last activity: [6 years, 11 months ago](https://wordpress.org/support/topic/syntax-errors-7/#post-11521020)
 * Status: resolved