二十二个儿童主题移动菜单不起作用

时间:2014-10-16 作者:Steve

我有一个非常简单的儿童主题,即“212Active”,但按下时移动菜单不会展开。

这是标题。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" />
<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(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
  <?php $header_image = get_header_image();             if ( ! empty( $header_image ) ) : ?>
  <a href="<?php echo esc_url( home_url( \'/\' ) ); ?>"><img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
  <?php endif; ?>
  <nav id="site-navigation" class="main-navigation" role="navigation">
    <h3 class="menu-toggle">
      <?php _e( \'Menu\', \'twentytwelve\' ); ?>
    </h3>
    <a class="assistive-text" href="#content" title="<?php esc_attr_e( \'Skip to content\', \'twentytwelve\' ); ?>">
    <?php _e( \'Skip to content\', \'twentytwelve\' ); ?>
    </a>
    <?php wp_nav_menu( array( \'theme_location\' => \'primary\', \'menu_class\' => \'nav-menu\' ) ); ?>
  </nav>
  <!-- #site-navigation --> <!--<hgroup>                        <h1 class="site-title"><a href="<?php echo esc_url( home_url( \'/\' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( \'name\', \'display\' ) ); ?>" rel="home"><?php bloginfo( \'name\' ); ?></a></h1>                        <h2 class="site-description"><?php bloginfo( \'description\' ); ?></h2>           </hgroup>--> </header>
<!-- #masthead -->
<div id="main" class="wrapper">
这里是风格。css:

/*
Theme Name: Vincent Men\'s Shed
Description: Custom theme
Author: Steve Doig
Template: twentytwelve
version: 0.1
*/

@import url("../twentytwelve/style.css");

@media screen and (min-width: 600px) {
  body .site {
    padding: 0;
    max-width: 1000px;
    max-width: 71.42857142rem;
  }
  .site-header {
    padding: 0;
  }
  .header-image {
    margin-top: 0;
  }
  header > a {
    background-color: #EC3607;
  }
  header hgroup, header nav {
    padding: 0 2em;
  }
  header nav {
    background: #2f2f2f; /* Old browsers */
    /* IE9 SVG, needs conditional override of \'filter\' to \'none\' */
    background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJmMmYyZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMwYjBiMGIiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
    background: -moz-linear-gradient(top, #2f2f2f 0%, #0b0b0b 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2f2f2f), color-stop(100%,#0b0b0b)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2f2f2f 0%,#0b0b0b 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2f2f2f 0%,#0b0b0b 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #2f2f2f 0%,#0b0b0b 100%); /* IE10+ */
    background: linear-gradient(to bottom, #2f2f2f 0%,#0b0b0b 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#2f2f2f\', endColorstr=\'#0b0b0b\',GradientType=0 ); /* IE6-8 */
  }
  .main-navigation {
    margin-top: 0;
  }
  .main-navigation li a {
    color: #eee;
  }
  .main-navigation li a:hover {
    color: #fff;
  }
  .main-navigation .current-menu-item > a, .main-navigation .current-menu-ancestor > a, .main-navigation .current_page_item > a, .main-navigation .current_page_ancestor > a {
    color: #fff;
  }
  .main-navigation ul.nav-menu, .main-navigation div.nav-menu > ul {
    border: none;
  }
  .main-navigation ul li ul li a {
    color: #000;
  }
  .main-navigation li.current-menu-item {
    background-color: #fff;
  }
  .main-navigation li.current-menu-item a {
    color: #000;
  }
  #main {
    padding: 2em;
  }
  .entry-header .entry-title {
    font-weight: bold;
  }
  .site-content {
    margin: 0;
  }
  .site-content article {
    margin-bottom: 28px;
    margin-bottom: 2rem;
  }
  footer[role="contentinfo"] {
    margin-top: 0;
  }
  .main-navigation li {
    padding: 0 1.5rem;
    margin: 0;
    position: relative;
  }
}
这里是函数。php:

<?php

function add_require_scripts_files() {
 wp_enqueue_style(\'layout\', get_stylesheet_directory_uri().\'/style.css\', array(), \'1.0.0\', "all");        
}

add_action( \'wp_enqueue_scripts\', \'add_require_scripts_files\' );

function wpse_filter_child_cats( $query ) {

if ( $query->is_category ) {
    $queried_object = get_queried_object();
    $child_cats = (array) get_term_children( $queried_object->term_id, \'category\' );

    if ( ! $query->is_admin )
        //exclude the posts in child categories
        $query->set( \'category__not_in\', array_merge( $child_cats ) );
    }

    return $query;
}
add_filter( \'pre_get_posts\', \'wpse_filter_child_cats\' );

add_filter(\'body_class\',\'twentytwelvechild_body_class_adapt\',20);
function twentytwelvechild_body_class_adapt( $classes ) {

        if ( is_category( \'newsletter\' ) )
                $classes[] = \'full-width\';

        return $classes;
}
我看不出是什么干扰了手机菜单。

有什么建议吗?

2 个回复
最合适的回答,由SO网友:bobbingwide 整理而成

我也有同样的问题。在base Twenty12主题中,代码发生了更改,因此站点导航从h3button.

您需要更新标题。要使用的子主题中的php文件

<button class="menu-toggle"><?php _e( \'Menu\', \'twentytwelve\' ); ?></button>
参见WordPressTRAC #28824 comment 13

从v1升级基本主题时会出现问题。4至v1。它不仅限于移动设备-您可以在窗口宽度小于600像素的情况下重新创建问题。

SO网友:Mithun Sarker Shuvro

wp_nav_menu(
 array(
 \'theme_location\' => \'primary\',
 \'menu_class\' => \'nav-menu\' ,
 \'container\'  =>FALSE
) 
)
试试这个,只需添加\'container\' =>FALSE 导航菜单阵列

结束

相关推荐

Problem with custom menus

在菜单上,我说的是自定义菜单,我有一个带有几列的页脚,每列都有一个项目列表,每列菜单都需要从wp admin上的菜单选项进行更新,所以我创建了关于函数的部分。调用菜单并在页脚上添加每个菜单的php。php文档,类似于:<?php wp_nav_menu( array(\'menu\' => \'f-1\', \'menu_class\' => \'\', \'container\' => \'nav\' )); ?> <?php wp_nav_menu( arr