質問編集履歴

2

追記

2017/02/03 12:35

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,81 @@
15
15
  このテンプレートのheadタグにwp_headを挿入するとテーマのcssが読み込まれているのか、スタイルが崩れてしまいます。
16
16
 
17
17
  外すと元のhtmlと同じスタイルに戻ります。
18
+
19
+
20
+
21
+ 追記。
22
+
23
+ テーマはTwenty Seventeenを使っています。
24
+
25
+ 以下のテンプレートのheadに<?php wp_head(); ?>を挿入すると
26
+
27
+ ```php
28
+
29
+ <?php
30
+
31
+ /*
32
+
33
+ Template Name: TEST
34
+
35
+ */
36
+
37
+ ?>
38
+
39
+ <!DOCTYPE html>
40
+
41
+ <html>
42
+
43
+ <head>
44
+
45
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
46
+
47
+ <title></title>
48
+
49
+ <?php wp_head(); ?>
50
+
51
+ <style>
52
+
53
+ * {margin: 0; padding: 0;}
54
+
55
+ html {background-color: #eee}
56
+
57
+ body {background-color: #fff;}
58
+
59
+ </style>
60
+
61
+ </head>
62
+
63
+ <body>
64
+
65
+ <h1>HELLO WORLD</h1>
66
+
67
+ </body>
68
+
69
+ </html>
70
+
71
+ ```
72
+
73
+ 以下のスタイルが現れます。
74
+
75
+ ```html
76
+
77
+ <style type="text/css" media="screen">
78
+
79
+ html { margin-top: 32px !important; }
80
+
81
+ * html body { margin-top: 32px !important; }
82
+
83
+ @media screen and ( max-width: 782px ) {
84
+
85
+ html { margin-top: 46px !important; }
86
+
87
+ * html body { margin-top: 46px !important; }
88
+
89
+ }
90
+
91
+ </style>
92
+
93
+ ```
94
+
95
+ その結果、ページの上の部分に変な余白が生まれてスタイルが崩れてしまいます。

1

2017/02/03 12:35

投稿

horik
horik

スコア44

test CHANGED
File without changes
test CHANGED
@@ -3,3 +3,15 @@
3
3
 
4
4
 
5
5
  wp_head()を読み込みたい理由はgoolgle analyticsプラグインを適用させたいためです。
6
+
7
+
8
+
9
+
10
+
11
+ 追記。
12
+
13
+ 既存のhtmlファイルをphpに書き換えてテンプレートファイルとします。
14
+
15
+ このテンプレートのheadタグにwp_headを挿入するとテーマのcssが読み込まれているのか、スタイルが崩れてしまいます。
16
+
17
+ 外すと元のhtmlと同じスタイルに戻ります。