回答編集履歴

3

typo

2020/02/07 05:54

投稿

CHERRY
CHERRY

スコア25175

test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/gallery.css">
14
14
 
15
- <?php enfif; ?>
15
+ <?php endif; ?>
16
16
 
17
17
  ```
18
18
 
@@ -40,6 +40,6 @@
40
40
 
41
41
  <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/gallery.css">
42
42
 
43
- <?php enfif; ?>
43
+ <?php endif; ?>
44
44
 
45
45
  ```

2

追記。

2020/02/07 05:54

投稿

CHERRY
CHERRY

スコア25175

test CHANGED
@@ -19,3 +19,27 @@
19
19
 
20
20
 
21
21
  ぐらいしか思いつかないですねぇ...
22
+
23
+
24
+
25
+ ----
26
+
27
+
28
+
29
+ あ、[is_page_template()](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/is_page_template) がありますね。
30
+
31
+
32
+
33
+ ほぼ同じですが...
34
+
35
+
36
+
37
+ ```
38
+
39
+ <?php if ( is_page_template("gallery.php") ): ?>
40
+
41
+ <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/gallery.css">
42
+
43
+ <?php enfif; ?>
44
+
45
+ ```

1

修正

2020/02/07 05:06

投稿

CHERRY
CHERRY

スコア25175

test CHANGED
@@ -2,15 +2,13 @@
2
2
 
3
3
 
4
4
 
5
- [get_page_template()](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_page_template) で、適用されているテンプレートファイル名(ファイルパス)が取得できるので、
5
+ [get_page_template()](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_page_template) で、適用されているテンプレートファイル名(ファイルパス)が取得できるので、ファイル名で、条件判断して
6
6
 
7
7
 
8
8
 
9
9
  ```
10
10
 
11
- <?php
12
-
13
- if ( basename(get_page_template()) == "gallery.php" ): ?>
11
+ <?php if ( basename(get_page_template()) == "gallery.php" ): ?>
14
12
 
15
13
  <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/gallery.css">
16
14