回答編集履歴

1

custom-page.php を元に single-custom.php にしたバージョンを追記

2020/05/10 07:00

投稿

Yasumichi
Yasumichi

スコア1773

test CHANGED
@@ -75,3 +75,307 @@
75
75
  【補足】
76
76
 
77
77
  custom-page.php を元にすると良いかもしれません。ただ、このファイル、Modern style と Classical style の両方の例が入っているのでどちらかを削除してから、利用するようです。
78
+
79
+
80
+
81
+ 【custom-page.php を元にしたバージョン】
82
+
83
+
84
+
85
+ custom-page.php を元に single-custom.php にしたバージョンも載せておきます。
86
+
87
+
88
+
89
+ ```php
90
+
91
+ <?php
92
+
93
+ /*
94
+
95
+ Template Name: Custom Page Example
96
+
97
+ */
98
+
99
+ if ( apply_filters( 'czr_ms', false ) ):
100
+
101
+ /*
102
+
103
+ * This is the reference Custom Page Example template if you use the theme Modern style
104
+
105
+ */
106
+
107
+
108
+
109
+ get_header();
110
+
111
+ // This hook is used to render the following elements(ordered by priorities) :
112
+
113
+ // slider
114
+
115
+ // singular thumbnail
116
+
117
+ do_action('__before_main_wrapper')
118
+
119
+ ?>
120
+
121
+
122
+
123
+ <div id="main-wrapper" class="section">
124
+
125
+
126
+
127
+ <?php
128
+
129
+ /*
130
+
131
+ * Featured Pages | 10
132
+
133
+ * Breadcrumbs | 20
134
+
135
+ */
136
+
137
+ do_action('__before_main_container')
138
+
139
+ ?>
140
+
141
+
142
+
143
+ <div class="<?php czr_fn_main_container_class() ?>" role="main">
144
+
145
+
146
+
147
+ <?php do_action('__before_content_wrapper'); ?>
148
+
149
+
150
+
151
+ <div class="<?php czr_fn_column_content_wrapper_class() ?>">
152
+
153
+
154
+
155
+ <?php do_action('__before_content'); ?>
156
+
157
+
158
+
159
+ <div id="content" class="<?php czr_fn_article_container_class() ?>">
160
+
161
+
162
+
163
+ <?php
164
+
165
+
166
+
167
+ do_action( '__before_loop' );
168
+
169
+
170
+
171
+ if ( have_posts() ) {
172
+
173
+ /**
174
+
175
+ * this will render the WordPress loop template located in templates/content/loop.php
176
+
177
+ * that will be responsible to load the page part template located in templates/content/singular/page_content.php
178
+
179
+ */
180
+
181
+ czr_fn_render_template( 'loop' );
182
+
183
+ }
184
+
185
+
186
+
187
+ /*
188
+
189
+ * Optionally attached to this hook :
190
+
191
+ * Comments | 30
192
+
193
+ */
194
+
195
+ do_action( '__after_loop' );
196
+
197
+ ?>
198
+
199
+ <!-- Edit start -->
200
+
201
+
202
+
203
+ <div class="example">
204
+
205
+ <?php
206
+
207
+ $image = get_post_meta($post->ID, 'c_mainimage', true);
208
+
209
+ $size = 'medium'; // (thumbnail, medium, large, full or custom size)
210
+
211
+ if( $image ) {
212
+
213
+ echo wp_get_attachment_image( $image, $size );
214
+
215
+ }
216
+
217
+ ?>
218
+
219
+ </div>
220
+
221
+ <dl>
222
+
223
+ <dt>アルバム名</dt><dd><?php echo get_post_meta($post->ID, 'example-album', true); ?></dd>
224
+
225
+ <dt>アーティスト名</dt><dd><?php echo get_post_meta($post->ID, 'example-artist', true); ?></dd>
226
+
227
+ <dt>レビュー</dt><dd><?php echo nl2br(get_post_meta($post->ID, 'example-review', true)); ?></dd>
228
+
229
+ </dl>
230
+
231
+
232
+
233
+ <!-- Edit end -->
234
+
235
+ </div>
236
+
237
+
238
+
239
+ <?php
240
+
241
+ /*
242
+
243
+ * Optionally attached to this hook :
244
+
245
+ * Comments | 30
246
+
247
+ */
248
+
249
+ do_action('__after_content'); ?>
250
+
251
+
252
+
253
+ <?php
254
+
255
+ /*
256
+
257
+ * SIDEBARS
258
+
259
+ */
260
+
261
+ if ( czr_fn_is_registered_or_possible('left_sidebar') )
262
+
263
+ get_sidebar( 'left' );
264
+
265
+
266
+
267
+ if ( czr_fn_is_registered_or_possible('right_sidebar') )
268
+
269
+ get_sidebar( 'right' );
270
+
271
+ ?>
272
+
273
+
274
+
275
+ </div><!-- .column-content-wrapper -->
276
+
277
+ <?php do_action('__after_content_wrapper'); ?>
278
+
279
+
280
+
281
+
282
+
283
+ </div><!-- .container -->
284
+
285
+
286
+
287
+ <?php do_action('__after_main_container'); ?>
288
+
289
+
290
+
291
+ </div><!-- #main-wrapper -->
292
+
293
+
294
+
295
+ <?php do_action('__after_main_wrapper'); ?>
296
+
297
+
298
+
299
+ <?php
300
+
301
+ if ( czr_fn_is_registered_or_possible('posts_navigation') ) :
302
+
303
+ ?>
304
+
305
+ <div class="container-fluid">
306
+
307
+ <?php
308
+
309
+ czr_fn_render_template( "content/singular/navigation/singular_posts_navigation" );
310
+
311
+ ?>
312
+
313
+ </div>
314
+
315
+ <?php endif ?>
316
+
317
+
318
+
319
+ <?php get_footer() ?>
320
+
321
+ <?php
322
+
323
+ return;
324
+
325
+ endif;
326
+
327
+
328
+
329
+
330
+
331
+ ```
332
+
333
+
334
+
335
+ Modern style を残して、`<!-- Edit start -->` から `<!-- Edit end -->` までが追記部分です。
336
+
337
+
338
+
339
+ 以下に追記部分を抜粋します。
340
+
341
+
342
+
343
+ ```php
344
+
345
+ <!-- Edit start -->
346
+
347
+
348
+
349
+ <div class="example">
350
+
351
+ <?php
352
+
353
+ $image = get_post_meta($post->ID, 'c_mainimage', true);
354
+
355
+ $size = 'medium'; // (thumbnail, medium, large, full or custom size)
356
+
357
+ if( $image ) {
358
+
359
+ echo wp_get_attachment_image( $image, $size );
360
+
361
+ }
362
+
363
+ ?>
364
+
365
+ </div>
366
+
367
+ <dl>
368
+
369
+ <dt>アルバム名</dt><dd><?php echo get_post_meta($post->ID, 'example-album', true); ?></dd>
370
+
371
+ <dt>アーティスト名</dt><dd><?php echo get_post_meta($post->ID, 'example-artist', true); ?></dd>
372
+
373
+ <dt>レビュー</dt><dd><?php echo nl2br(get_post_meta($post->ID, 'example-review', true)); ?></dd>
374
+
375
+ </dl>
376
+
377
+
378
+
379
+ <!-- Edit end -->
380
+
381
+ ```