質問編集履歴
2
functions.phpを記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -58,4 +58,37 @@
|
|
58
58
|
|
59
59
|
</div><!--end header-inner-->
|
60
60
|
</header>
|
61
|
+
```
|
62
|
+
|
63
|
+
↓functions.php
|
64
|
+
```
|
65
|
+
<?php
|
66
|
+
//テーマのセットアップ
|
67
|
+
// HTML5でマークアップさせる
|
68
|
+
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );
|
69
|
+
// Feedのリンクを自動で生成する
|
70
|
+
add_theme_support( 'automatic-feed-links' );
|
71
|
+
//アイキャッチ画像を使用する設定
|
72
|
+
add_theme_support( 'post-thumbnails' );
|
73
|
+
//カスタムメニュー
|
74
|
+
register_nav_menu( 'header-nav', ' ヘッダーナビゲーション ' );
|
75
|
+
register_nav_menu( 'footer-nav', ' フッターナビゲーション ' );
|
76
|
+
//メニュー用jsの読み込み
|
77
|
+
function navbutton_scripts(){
|
78
|
+
wp_enqueue_script( 'navbutton_script', get_template_directory_uri() .'/js/navbutton.js', array('jquery'), '', true );
|
79
|
+
}
|
80
|
+
add_action( 'wp_enqueue_scripts' , 'navbutton_scripts' );
|
81
|
+
|
82
|
+
//サイドバーにウィジェット追加
|
83
|
+
function widgetarea_init() {
|
84
|
+
register_sidebar(array(
|
85
|
+
'name'=>'サイドバー',
|
86
|
+
'id' => 'side-widget',
|
87
|
+
'before_widget'=>'<div id="%1$s" class="%2$s sidebar-wrapper">',
|
88
|
+
'after_widget'=>'</div>',
|
89
|
+
'before_title' => '<h4 class="sidebar-title">',
|
90
|
+
'after_title' => '</h4>'
|
91
|
+
));
|
92
|
+
}
|
93
|
+
add_action( 'widgets_init', 'widgetarea_init' );
|
61
94
|
```
|
1
header.phpを記載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,61 @@
|
|
1
1
|
wordpressでオリジナルテーマを作成して遊んでいるのですが、ヘッダーの画像が切り替わりません。
|
2
2
|
それぞれテーマフォルダ内に、別の画像を格納しているのですが、片一方の画像しか表示されません。
|
3
|
-
どのような原因が考えられるでしょうか。
|
3
|
+
どのような原因が考えられるでしょうか。
|
4
|
+
|
5
|
+
↓header.php
|
6
|
+
|
7
|
+
```
|
8
|
+
<!DOCTYPE html><!--htmlで書かれていることを宣言-->
|
9
|
+
<html lang="ja"><!--日本語のサイトであることを指定-->
|
10
|
+
<head>
|
11
|
+
<meta charset="utf-8"><!--エンコードがUTF-8であることを指定-->
|
12
|
+
<meta name="viewport"
|
13
|
+
content="width=device-width, initial-scale=1.0 "><!--viewportの設定-->
|
14
|
+
<link rel="stylesheet" href="<?php echo get_stylesheet_uri(); ?>"><!--スタイルシートの呼び出し-->
|
15
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous"><!--font-awesomeのスタイルシートの呼び出し-->
|
16
|
+
|
17
|
+
<?php wp_head(); ?><!--システム・プラグイン用-->
|
18
|
+
</head>
|
19
|
+
<body <?php body_class(); ?>>
|
20
|
+
<header>
|
21
|
+
<div class="header-inner">
|
22
|
+
<?php
|
23
|
+
if(is_home()) {
|
24
|
+
$title_tag_start = '<h1 class="site-title">';
|
25
|
+
$title_tag_end = '</h1>';
|
26
|
+
} else {
|
27
|
+
$title_tag_start = '<p class="site-title">';
|
28
|
+
$title_tag_end = '</p>';
|
29
|
+
}
|
30
|
+
?>
|
31
|
+
|
32
|
+
|
33
|
+
<div class="site-title-wrap">
|
34
|
+
<?php echo $title_tag_start; ?>
|
35
|
+
<a href="<?php echo home_url(); ?>">
|
36
|
+
<img src="<?php echo get_template_directory_uri() ?>/images/title.png">
|
37
|
+
</a>
|
38
|
+
<?php echo $title_tag_end; ?>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
<!--スマホ用メニューボタン-->
|
44
|
+
<button type="button" id="navbutton" class="navbutton">
|
45
|
+
<i class="fas fa-bars"></i>
|
46
|
+
</button>
|
47
|
+
|
48
|
+
<!--ヘッダーメニュー-->
|
49
|
+
<div id="header-nav-wrap" class="header-nav-wrap">
|
50
|
+
<?php wp_nav_menu( array(
|
51
|
+
'theme_location' => 'header-nav',
|
52
|
+
'container' => 'nav',
|
53
|
+
'container_class' => 'header-nav',
|
54
|
+
'container_id' => 'header-nav',
|
55
|
+
'fallback_cb' => ''
|
56
|
+
) ); ?>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</div><!--end header-inner-->
|
60
|
+
</header>
|
61
|
+
```
|