• Resolved Zeokat

    (@zeokat)


    I spend some hours trying to add the schema.org markup to WordPress menus but couldn′t achieve a solution.

    The code should be like this:
    <nav class="nav-primary" role="navigation" itemscope="itemscope" itemtype="https://schema.org/SiteNavigationElement">

    But WordPress only allows customize the container: https://codex.www.ads-software.com/Function_Reference/wp_nav_menu

    My ouput now is:
    <nav class="vi-top-menu">

    I still need to add role=”navigation” and the schema markup.

    Any advice or help on this?

    Thanks in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Would something like this work?

    <?php wp_nav_menu( array('container' => '',
    	'items_wrap' => '<nav class="nav-primary" role="navigation" itemscope="itemscope" itemtype="https://schema.org/SiteNavigationElement"><ul id="%1$s" class="%2$s">%3$s</ul></nav>') ); ?>
    Thread Starter Zeokat

    (@zeokat)

    Thanks pyjamaman, it works very good. With that solution the nav container is hardcoded so i have to get rid of container added dinamically by WordPress with something like this:

    <?php wp_nav_menu( array( 'theme_location' => 'top-menu', 'container' => false, 'items_wrap' => '<nav class="nav-primary" role="navigation" itemscope="itemscope" itemtype="https://schema.org/SiteNavigationElement"><ul>%3$s</ul></nav>' ) ); ?>

    P.S: sorry for my english lol

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding schema.org markup to wordpress menus’ is closed to new replies.