回答編集履歴
1
custom-page.php を元に single-custom.php にしたバージョンを追記
answer
CHANGED
@@ -36,4 +36,156 @@
|
|
36
36
|
[WordPressにCSSやJavascriptを個別設定できるように | D-NET](https://forsmile.jp/development/34/)
|
37
37
|
|
38
38
|
【補足】
|
39
|
-
custom-page.php を元にすると良いかもしれません。ただ、このファイル、Modern style と Classical style の両方の例が入っているのでどちらかを削除してから、利用するようです。
|
39
|
+
custom-page.php を元にすると良いかもしれません。ただ、このファイル、Modern style と Classical style の両方の例が入っているのでどちらかを削除してから、利用するようです。
|
40
|
+
|
41
|
+
【custom-page.php を元にしたバージョン】
|
42
|
+
|
43
|
+
custom-page.php を元に single-custom.php にしたバージョンも載せておきます。
|
44
|
+
|
45
|
+
```php
|
46
|
+
<?php
|
47
|
+
/*
|
48
|
+
Template Name: Custom Page Example
|
49
|
+
*/
|
50
|
+
if ( apply_filters( 'czr_ms', false ) ):
|
51
|
+
/*
|
52
|
+
* This is the reference Custom Page Example template if you use the theme Modern style
|
53
|
+
*/
|
54
|
+
|
55
|
+
get_header();
|
56
|
+
// This hook is used to render the following elements(ordered by priorities) :
|
57
|
+
// slider
|
58
|
+
// singular thumbnail
|
59
|
+
do_action('__before_main_wrapper')
|
60
|
+
?>
|
61
|
+
|
62
|
+
<div id="main-wrapper" class="section">
|
63
|
+
|
64
|
+
<?php
|
65
|
+
/*
|
66
|
+
* Featured Pages | 10
|
67
|
+
* Breadcrumbs | 20
|
68
|
+
*/
|
69
|
+
do_action('__before_main_container')
|
70
|
+
?>
|
71
|
+
|
72
|
+
<div class="<?php czr_fn_main_container_class() ?>" role="main">
|
73
|
+
|
74
|
+
<?php do_action('__before_content_wrapper'); ?>
|
75
|
+
|
76
|
+
<div class="<?php czr_fn_column_content_wrapper_class() ?>">
|
77
|
+
|
78
|
+
<?php do_action('__before_content'); ?>
|
79
|
+
|
80
|
+
<div id="content" class="<?php czr_fn_article_container_class() ?>">
|
81
|
+
|
82
|
+
<?php
|
83
|
+
|
84
|
+
do_action( '__before_loop' );
|
85
|
+
|
86
|
+
if ( have_posts() ) {
|
87
|
+
/**
|
88
|
+
* this will render the WordPress loop template located in templates/content/loop.php
|
89
|
+
* that will be responsible to load the page part template located in templates/content/singular/page_content.php
|
90
|
+
*/
|
91
|
+
czr_fn_render_template( 'loop' );
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* Optionally attached to this hook :
|
96
|
+
* Comments | 30
|
97
|
+
*/
|
98
|
+
do_action( '__after_loop' );
|
99
|
+
?>
|
100
|
+
<!-- Edit start -->
|
101
|
+
|
102
|
+
<div class="example">
|
103
|
+
<?php
|
104
|
+
$image = get_post_meta($post->ID, 'c_mainimage', true);
|
105
|
+
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
|
106
|
+
if( $image ) {
|
107
|
+
echo wp_get_attachment_image( $image, $size );
|
108
|
+
}
|
109
|
+
?>
|
110
|
+
</div>
|
111
|
+
<dl>
|
112
|
+
<dt>アルバム名</dt><dd><?php echo get_post_meta($post->ID, 'example-album', true); ?></dd>
|
113
|
+
<dt>アーティスト名</dt><dd><?php echo get_post_meta($post->ID, 'example-artist', true); ?></dd>
|
114
|
+
<dt>レビュー</dt><dd><?php echo nl2br(get_post_meta($post->ID, 'example-review', true)); ?></dd>
|
115
|
+
</dl>
|
116
|
+
|
117
|
+
<!-- Edit end -->
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<?php
|
121
|
+
/*
|
122
|
+
* Optionally attached to this hook :
|
123
|
+
* Comments | 30
|
124
|
+
*/
|
125
|
+
do_action('__after_content'); ?>
|
126
|
+
|
127
|
+
<?php
|
128
|
+
/*
|
129
|
+
* SIDEBARS
|
130
|
+
*/
|
131
|
+
if ( czr_fn_is_registered_or_possible('left_sidebar') )
|
132
|
+
get_sidebar( 'left' );
|
133
|
+
|
134
|
+
if ( czr_fn_is_registered_or_possible('right_sidebar') )
|
135
|
+
get_sidebar( 'right' );
|
136
|
+
?>
|
137
|
+
|
138
|
+
</div><!-- .column-content-wrapper -->
|
139
|
+
<?php do_action('__after_content_wrapper'); ?>
|
140
|
+
|
141
|
+
|
142
|
+
</div><!-- .container -->
|
143
|
+
|
144
|
+
<?php do_action('__after_main_container'); ?>
|
145
|
+
|
146
|
+
</div><!-- #main-wrapper -->
|
147
|
+
|
148
|
+
<?php do_action('__after_main_wrapper'); ?>
|
149
|
+
|
150
|
+
<?php
|
151
|
+
if ( czr_fn_is_registered_or_possible('posts_navigation') ) :
|
152
|
+
?>
|
153
|
+
<div class="container-fluid">
|
154
|
+
<?php
|
155
|
+
czr_fn_render_template( "content/singular/navigation/singular_posts_navigation" );
|
156
|
+
?>
|
157
|
+
</div>
|
158
|
+
<?php endif ?>
|
159
|
+
|
160
|
+
<?php get_footer() ?>
|
161
|
+
<?php
|
162
|
+
return;
|
163
|
+
endif;
|
164
|
+
|
165
|
+
|
166
|
+
```
|
167
|
+
|
168
|
+
Modern style を残して、`<!-- Edit start -->` から `<!-- Edit end -->` までが追記部分です。
|
169
|
+
|
170
|
+
以下に追記部分を抜粋します。
|
171
|
+
|
172
|
+
```php
|
173
|
+
<!-- Edit start -->
|
174
|
+
|
175
|
+
<div class="example">
|
176
|
+
<?php
|
177
|
+
$image = get_post_meta($post->ID, 'c_mainimage', true);
|
178
|
+
$size = 'medium'; // (thumbnail, medium, large, full or custom size)
|
179
|
+
if( $image ) {
|
180
|
+
echo wp_get_attachment_image( $image, $size );
|
181
|
+
}
|
182
|
+
?>
|
183
|
+
</div>
|
184
|
+
<dl>
|
185
|
+
<dt>アルバム名</dt><dd><?php echo get_post_meta($post->ID, 'example-album', true); ?></dd>
|
186
|
+
<dt>アーティスト名</dt><dd><?php echo get_post_meta($post->ID, 'example-artist', true); ?></dd>
|
187
|
+
<dt>レビュー</dt><dd><?php echo nl2br(get_post_meta($post->ID, 'example-review', true)); ?></dd>
|
188
|
+
</dl>
|
189
|
+
|
190
|
+
<!-- Edit end -->
|
191
|
+
```
|