質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

Q&A

1回答

2003閲覧

Wordpressでグローバルメニューがスマホでは表示されるのにパソコンでは表示されない

Malas

総合スコア112

WordPress

WordPressは、PHPで開発されているオープンソースのブログソフトウェアです。データベース管理システムにはMySQLを用いています。フリーのブログソフトウェアの中では最も人気が高く、PHPとHTMLを使って簡単にテンプレートをカスタマイズすることができます。

0グッド

0クリップ

投稿2018/12/08 04:35

前提・実現したいこと

Wordpressでサイトを作成しております。
グローバルメニューがスマホでは表示されるのにパソコンでは表示されないです。
header.phpをよく開いていたので原因があるのではないかと思い確認していますが、
解決にはいたりません。

こちらの対処方法を教えていただけますでしょうか?

### header.php

<!doctype html> <!--[if lt IE 7]><html <?php language_attributes(); ?> class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--> <!--[if (IE 7)&!(IEMobile)]><html <?php language_attributes(); ?> class="no-js lt-ie9 lt-ie8"><![endif]--> <!--[if (IE 8)&!(IEMobile)]><html <?php language_attributes(); ?> class="no-js lt-ie9"><![endif]--> <!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> class="no-js"><!--<![endif]--> <head> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title><?php wp_title(''); ?></title> <meta name="HandheldFriendly" content="True"> <meta name="MobileOptimized" content="320"> <meta name="viewport" content="width=device-width, initial-scale=1"/> <?php if ( get_theme_mod( 'opencage_appleicon' ) ) : ?><link rel="apple-touch-icon" href="<?php echo get_theme_mod( 'opencage_appleicon' ); ?>"><?php endif; ?> <?php if ( get_theme_mod( 'opencage_favicon' ) ) : ?><link rel="icon" href="<?php echo get_theme_mod( 'opencage_favicon' ); ?>"><?php endif; ?> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>"> <!--[if IE]> <?php if ( get_theme_mod( 'opencage_favicon_ie' ) ) : ?><link rel="shortcut icon" href="<?php echo get_theme_mod( 'opencage_favicon_ie' ); ?>"><?php endif; ?> <![endif]--> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="//css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js"></script> <![endif]--> <?php get_template_part( 'head' ); ?> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="container"> <?php if(!is_page_template( 'page-lp.php' ) && !is_singular( 'post_lp' )): ?> <?php if ( get_option( 'side_options_description' ) ) : ?><p class="site_description"><?php bloginfo('description'); ?></p><?php endif; ?> <header class="header animated fadeIn <?php if ( wp_is_mobile() ) : ?>headercenter<?php else:?><?php echo get_option( 'side_options_headercenter' ); ?><?php endif; ?>" role="banner"> <div id="inner-header" class="wrap cf"> <div id="logo" class="gf <?php echo esc_html(get_option('opencage_logo_size'));?>"> <?php if ( is_home() || is_front_page() ) : ?> <?php if ( get_theme_mod( 'opencage_logo' ) ) : ?> <h1 class="h1 img"><a href="<?php echo esc_url(home_url()); ?>" rel="nofollow"><img src="<?php echo get_theme_mod( 'opencage_logo' ); ?>" alt="<?php bloginfo('name'); ?>"></a></h1> <?php else : ?> <h1 class="h1 text"><a href="<?php echo esc_url(home_url()); ?>" rel="nofollow"><?php bloginfo('name'); ?></a></h1> <?php endif; ?> <?php else: ?> <?php if ( get_theme_mod( 'opencage_logo' ) ) : ?> <p class="h1 img"><a href="<?php echo esc_url(home_url()); ?>"><img src="<?php echo get_theme_mod( 'opencage_logo' ); ?>" alt="<?php bloginfo('name'); ?>"></a></p> <?php else : ?> <p class="h1 text"><a href="<?php echo esc_url(home_url()); ?>"><?php bloginfo('name'); ?></a></p> <?php endif; ?> <?php endif; ?> </div> <?php if(!get_option('side_options_header_search')):?> <a href="#searchbox" data-remodal-target="searchbox" class="nav_btn search_btn"><span class="text gf">search</span></a> <?php endif;?> <?php if (!is_mobile() && has_nav_menu('main-nav')):?> <nav id="g_nav" role="navigation"> <?php wp_nav_menu(array( 'container' => false, 'container_class' => 'menu cf', 'menu' => __( 'グローバルナビ' ), 'menu_class' => 'nav top-nav cf', 'theme_location' => 'main-nav', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'fallback_cb' => '' )); ?> </nav> <?php endif;?> <a href="#spnavi" data-remodal-target="spnavi" class="nav_btn"><span class="text gf">menu</span></a> <?php if(is_mobile() && has_nav_menu('main-nav-sp')):?> <div class="g_nav-sp animated fadeIn"> <?php wp_nav_menu(array( 'container' => 'nav', 'container_class' => 'menu-sp cf', 'menu' => __( 'グローバルナビ(スマートフォン)' ), 'menu_class' => 'top-nav', 'theme_location' => 'main-nav-sp', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'fallback_cb' => '' )); ?> </div> <?php endif;?> </div> </header> <?php if (is_active_sidebar('sidebar-sp')):?> <div class="remodal" data-remodal-id="spnavi" data-remodal-options="hashTracking:false"> <button data-remodal-action="close" class="remodal-close"><span class="text gf">CLOSE</span></button> <?php dynamic_sidebar( 'sidebar-sp' ); ?> <button data-remodal-action="close" class="remodal-close"><span class="text gf">CLOSE</span></button> </div> <?php else:?> <div class="remodal" data-remodal-id="spnavi" data-remodal-options="hashTracking:false"> <button data-remodal-action="close" class="remodal-close"><span class="text gf">CLOSE</span></button> <?php wp_nav_menu(array( 'container' => false, 'container_class' => 'sp_g_nav menu cf', 'menu' => __( 'グローバルナビ' ), 'menu_class' => 'sp_g_nav nav top-nav cf', 'theme_location' => 'main-nav', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'fallback_cb' => '' )); ?> <button data-remodal-action="close" class="remodal-close"><span class="text gf">CLOSE</span></button> </div> <?php endif; ?> <?php if(!get_option('side_options_header_search')):?> <div class="remodal searchbox" data-remodal-id="searchbox" data-remodal-options="hashTracking:false"> <div class="search cf"><dl><dt>キーワードで記事を検索</dt><dd><?php get_search_form(); ?></dd></dl></div> <button data-remodal-action="close" class="remodal-close"><span class="text gf">CLOSE</span></button> </div> <?php endif;?> <?php if ( get_option('other_options_headerunderlink') && get_option('other_options_headerundertext') ) : ?> <div class="header-info"><a<?php if(get_option('other_options_headerunderlink_target')):?> target="_blank"<?php endif;?> style="background-color: <?php echo get_theme_mod( 'other_options_headerunderlink_bgcolor'); ?>;" href="<?php echo esc_html(get_option('other_options_headerunderlink'));?>"><?php echo esc_html(get_option('other_options_headerundertext'));?></a></div> <?php endif;?> <?php get_template_part( 'parts_homeheader' ); ?> <?php if(get_option('side_options_pannavi', 'pannavi_on') == 'pannavi_on' || !get_option('side_options_pannavi')){ breadcrumb(); } ?> <?php endif; ?>

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/12/10 09:20

スマートフォン用のグローバルメニューとパソコン用のグローバルメニューの両方をそれぞれ作成してあるのにパソコン用だけ表示されないということですか?
guest

回答1

0

パソコン用の wp_nav_menu()containerfalse を指定されてますが、
この値を divnav に変えた場合、想定通りの結果に変わりますか?

投稿2018/12/27 08:00

Sohaya

総合スコア254

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問