I\'am trying to make a wordpress website accessibility compliant,但我遇到了菜单栏的问题。它使用了一个基于二十点十二分的修改后的数字。
我需要将“ul”标签更改为“ol”,这是使其符合要求所必需的。(我试过了Edit HTML of Wordpress navigation bar 下面的解决方案,但我真的无法理解其中的walker解决方案)。非常感谢。
这就是标题的方式。php文件如下所示:
<?php
/**
* The Header for our theme.
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( \'charset\' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title( \'|\', true, \'right\' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( \'pingback_url\' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<![endif]-->
<?php wp_head(); ?>
<script>
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');
ga(\'create\', \'UA-57162369-1\', \'auto\');
ga(\'send\', \'pageview\');
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
// DOM ready
$(function() {
// Create the dropdown base
$("<select />").appendTo("nav");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Menu"
}).appendTo("nav select");
// Populate dropdown with menu items
$("nav a").each(function() {
var el = $(this);
$("<option />", {
"value" : el.attr("href"),
"text" : el.text()
}).appendTo("nav select");
});
// To make dropdown actually work
// To make more unobtrusive: http://css-tricks.com/4064-unobtrusive-page-changer/
$("nav select").change(function() {
window.location = $(this).find("option:selected").val();
});
});
</script>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<div id="masthead" class="site-header" >
<div class="logo">
<a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( \'name\', \'display\' ) ); ?>" rel="home">
<img src="<?php echo get_template_directory_uri(); ?>/images/logo.png" alt="<?php echo esc_attr( get_bloginfo( \'name\', \'display\' ) ); ?>" />
</a>
</div>
<div class="nav-right">
<div class="header-call"><a href="/contact-us/">Call us today on <span>02 6247 3611</span></a></div>
<nav id="site-navigation" class="main-navigation" >
<?php wp_nav_menu( array( \'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\' ) ); ?>
</nav><!-- #site-navigation -->
<nav id="site-navigation2" class="main-navigation2" role="navigation">
<?php wp_nav_menu( array( \'theme_location\' => \'secondary\', \'menu_class\' => \'nav-menu\' ) ); ?>
</nav><!-- #site-navigation -->
</div>
</div><!-- #masthead -->
<div id="main" class="wrapper">
SO网友:bravokeyl
“items\\u wrap”(字符串):应如何包装列表项。默认为带有id和类的ul>。使用带编号占位符的printf()格式。
违约items_wrap
是<ul id="%1$s" class="%2$s">%3$s</ul>
你可以通过items_wrap
的参数wp_nav_menu
像这样。
wp_nav_menu(
array( \'theme_location\' => \'primary\',
\'menu_class\' => \'nav-menu\',
\'items_wrap\' => \'<ol id="%1$s" class="%2$s">%3$s</ol>\'
)
);
“container”(字符串)是否包装ul,以及包装内容。默认“div”。
如果你想把ul
任何其他标签div
您可以使用
wp_nav_menu(
array( \'theme_location\' => \'primary\',
\'menu_class\' => \'nav-menu\',
\'container\' => \'section\' // default is div
)
);