質問編集履歴
1
コードを掲載しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,181 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
しかし同様にindex.phpを「single-{post-type}.php」にリネームし、
|
11
|
+
しかし同様にindex.phpを「single-{post-type}.php」にリネームし、以下のようにカスタムフィールド表示用のコードを記載したところ、投稿ページには何も表示されませんでした。
|
12
|
+
|
13
|
+
(「追記箇所」から「追記箇所ここまで」が自分で記載したコードです)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```PHP
|
18
|
+
|
19
|
+
<?php
|
20
|
+
|
21
|
+
/**
|
22
|
+
|
23
|
+
* The main template file. Includes the loop.
|
24
|
+
|
25
|
+
*
|
26
|
+
|
27
|
+
*
|
28
|
+
|
29
|
+
* @package Customizr
|
30
|
+
|
31
|
+
* @since Customizr 1.0
|
32
|
+
|
33
|
+
*/
|
34
|
+
|
35
|
+
if ( apply_filters( 'czr_ms', false ) ) {
|
36
|
+
|
37
|
+
do_action( 'czr_ms_tmpl' );
|
38
|
+
|
39
|
+
return;
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
?>
|
44
|
+
|
45
|
+
<?php do_action( '__before_main_wrapper' ); ##hook of the header with get_header ?>
|
46
|
+
|
47
|
+
<div id="main-wrapper" class="<?php echo implode(' ', apply_filters( 'tc_main_wrapper_classes' , array('container') ) ) ?>">
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<?php do_action( '__before_main_container' ); ##hook of the featured page (priority 10) and breadcrumb (priority 20)...and whatever you need! ?>
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<div class="container" role="main">
|
56
|
+
|
57
|
+
<div class="<?php echo implode(' ', apply_filters( 'tc_column_content_wrapper_classes' , array('row' ,'column-content-wrapper') ) ) ?>">
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<?php do_action( '__before_article_container'); ##hook of left sidebar?>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<div id="content" class="<?php echo implode(' ', apply_filters( 'tc_article_container_class' , array( CZR_utils::czr_fn_get_layout( czr_fn_get_id() , 'class' ) , 'article-container' ) ) ) ?>">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<?php do_action ('__before_loop');##hooks the heading of the list of post : archive, search... ?>
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<?php if ( czr_fn__f('__is_no_results') || is_404() ) : ##no search results or 404 cases ?>
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
<article <?php czr_fn__f('__article_selectors') ?>>
|
78
|
+
|
79
|
+
<?php do_action( '__loop' ); ?>
|
80
|
+
|
81
|
+
</article>
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
<?php endif; ?>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<?php if ( have_posts() && ! is_404() ) : ?>
|
90
|
+
|
91
|
+
<?php while ( have_posts() ) : ##all other cases for single and lists: post, custom post type, page, archives, search, 404 ?>
|
92
|
+
|
93
|
+
<?php the_post(); ?>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<?php do_action ('__before_article') ?>
|
98
|
+
|
99
|
+
<article <?php czr_fn__f('__article_selectors') ?>>
|
100
|
+
|
101
|
+
<?php do_action( '__loop' ); ?>
|
102
|
+
|
103
|
+
</article>
|
104
|
+
|
105
|
+
<!--追記箇所-->
|
106
|
+
|
107
|
+
<div class="example">
|
108
|
+
|
109
|
+
<?php
|
110
|
+
|
111
|
+
$image = get_field('c_mainimage');
|
112
|
+
|
113
|
+
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
|
114
|
+
|
115
|
+
if( $image ) {
|
116
|
+
|
117
|
+
echo wp_get_attachment_image( $image, $size );
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
?>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<dl>
|
126
|
+
|
127
|
+
<dt>アルバム名</dt><dd><?php the_field('example-album'); ?></dd>
|
128
|
+
|
129
|
+
<dt>アーティスト名</dt><dd><?php the_field('example-artist'); ?></dd>
|
130
|
+
|
131
|
+
<dt>レビュー</dt><dd><?php echo nl2br(get_post_meta($post->ID, 'example-review', true)); ?></dd>
|
132
|
+
|
133
|
+
</dl>
|
134
|
+
|
135
|
+
<!--追記箇所ここまで-->
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<?php do_action ('__after_article') ?>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<?php endwhile; ?>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<?php endif; ##end if have posts ?>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<?php do_action ('__after_loop');##hook of the comments and the posts navigation with priorities 10 and 20 ?>
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
<?php // <hr> introduced in july 2019 to fix https://github.com/presscustomizr/customizr/issues/1767 ?>
|
156
|
+
|
157
|
+
<hr class="featurette-divider tc-mobile-separator">
|
158
|
+
|
159
|
+
</div><!--.article-container -->
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<?php do_action( '__after_article_container'); ##hook of right sidebar ?>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
</div><!--.row -->
|
168
|
+
|
169
|
+
</div><!-- .container role: main -->
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<?php do_action( '__after_main_container' ); ?>
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
</div><!-- //#main-wrapper -->
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<?php do_action( '__after_main_wrapper' );##hook of the footer with get_footer ?>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
```
|
12
186
|
|
13
187
|
|
14
188
|
|