質問編集履歴
2
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,12 +20,14 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
解決策が思い浮かぶ方は、どんなアドバイスでも構いませんので力を貸していただきたいです。
|
23
|
+
解決策が思い浮かぶ方は、どんなアドバイスでも構いませんので力を貸していただきたいです。
|
24
|
+
|
25
|
+
```PHP
|
26
|
+
|
27
|
+
【funtions.php】
|
24
28
|
|
25
29
|
<?php
|
26
30
|
|
27
|
-
|
28
|
-
|
29
31
|
//概要(抜粋)の文字数
|
30
32
|
|
31
33
|
function my_length($length) {
|
@@ -428,7 +430,9 @@
|
|
428
430
|
|
429
431
|
|
430
432
|
|
433
|
+
``` PHP
|
434
|
+
|
431
|
-
|
435
|
+
【comments.php】
|
432
436
|
|
433
437
|
<div id="comment_area">
|
434
438
|
|
@@ -512,6 +516,4 @@
|
|
512
516
|
|
513
517
|
|
514
518
|
|
515
|
-
|
516
|
-
|
517
519
|
```
|
1
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,4 +20,498 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
解決策が思い浮かぶ方は、どんなアドバイスでも構いませんので力を貸していただきたいです。
|
23
|
+
解決策が思い浮かぶ方は、どんなアドバイスでも構いませんので力を貸していただきたいです。```functions.php
|
24
|
+
|
25
|
+
<?php
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
//概要(抜粋)の文字数
|
30
|
+
|
31
|
+
function my_length($length) {
|
32
|
+
|
33
|
+
return 50;
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
add_filter('excerpt_mblength','my_length');
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
//概要(抜粋)の省略記号
|
42
|
+
|
43
|
+
function my_more($more) {
|
44
|
+
|
45
|
+
return '…';
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
add_filter('excerpt_more', 'my_more');
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
//コンテンツの最大幅
|
56
|
+
|
57
|
+
if ( !isset( $content_width ) ) {
|
58
|
+
|
59
|
+
$content_width = 747;
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
//YouTubeのビデオ:<div>でマークアップ
|
70
|
+
|
71
|
+
function ytwrapper($return, $data, $url) {
|
72
|
+
|
73
|
+
if ($data->provider_name == 'YouTube') {
|
74
|
+
|
75
|
+
return '<div class="ytvideo">'.$return.'</div>';
|
76
|
+
|
77
|
+
} else {
|
78
|
+
|
79
|
+
return $return;
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
add_filter('oembed_dataparse','ytwrapper',10,3);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
//YouTubeのビデオ:キャッシュをクリア
|
94
|
+
|
95
|
+
//function clear_ytwrapper($post_id) {
|
96
|
+
|
97
|
+
// global $wp_embed;
|
98
|
+
|
99
|
+
// $wp_embed->delete_oembed_caches($post_id);
|
100
|
+
|
101
|
+
//}
|
102
|
+
|
103
|
+
//add_action('pre_post_update', 'clear_ytwrapper');
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
//アイキャッチ画像
|
112
|
+
|
113
|
+
add_theme_support( 'post-thumbnails' );
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
//編集画面の設定
|
122
|
+
|
123
|
+
function editor_setting($init) {
|
124
|
+
|
125
|
+
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre';
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
$style_formats = array(
|
130
|
+
|
131
|
+
array(
|
132
|
+
|
133
|
+
'title' => '補足情報',
|
134
|
+
|
135
|
+
'block' => 'div',
|
136
|
+
|
137
|
+
'classes' => 'point'
|
138
|
+
|
139
|
+
),
|
140
|
+
|
141
|
+
array(
|
142
|
+
|
143
|
+
'title' => '注意書き',
|
144
|
+
|
145
|
+
'block' => 'div',
|
146
|
+
|
147
|
+
'classes' => 'attention'
|
148
|
+
|
149
|
+
)
|
150
|
+
|
151
|
+
);
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
$init['style_formats'] = json_encode( $style_formats );
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
return $init;
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
add_filter('tiny_mce_before_init', 'editor_setting');
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
//スタイルメニューを有効化
|
174
|
+
|
175
|
+
function add_stylemenu( $buttons ){
|
176
|
+
|
177
|
+
array_splice( $buttons, 1, 0, 'styleselect' );
|
178
|
+
|
179
|
+
return $buttons;
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
add_filter( 'mce_buttons_2', 'add_stylemenu' );
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
// エディタスタイルシート
|
192
|
+
|
193
|
+
add_editor_style();
|
194
|
+
|
195
|
+
add_editor_style( '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css' );
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
// サムネイル画像
|
204
|
+
|
205
|
+
function mythumb( $size ) {
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
if( has_post_thumbnail() ) {
|
210
|
+
|
211
|
+
$postthumb = wp_get_attachment_image_src( get_post_thumbnail_id(), $size );
|
212
|
+
|
213
|
+
$url = $postthumb[0];
|
214
|
+
|
215
|
+
} else {
|
216
|
+
|
217
|
+
$url = get_template_directory_uri() . '/mainimage.jpg';
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
return $url;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
// トグルボタン
|
238
|
+
|
239
|
+
function navbtn_scripts() {
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
wp_enqueue_script( 'navbtn-script', get_template_directory_uri() .'/navbtn.js', array('jquery') );
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
add_action( 'wp_enqueue_scripts', 'navbtn_scripts' );
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
// ウィジェットエリア
|
256
|
+
|
257
|
+
register_sidebar( array(
|
258
|
+
|
259
|
+
'id' => 'submenu',
|
260
|
+
|
261
|
+
'name' => ' サブメニュー',
|
262
|
+
|
263
|
+
'description' => 'サイドバーに表示するウィジェットを指定。',
|
264
|
+
|
265
|
+
'before_widget' => '<aside id="%1$s" class="mymenu widget %2$s">',
|
266
|
+
|
267
|
+
'after_widget' => '</aside>',
|
268
|
+
|
269
|
+
'before_title' => '<h2 class="widgettitle">',
|
270
|
+
|
271
|
+
'after_title' => '</h2>'
|
272
|
+
|
273
|
+
) );
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
register_sidebar( array(
|
278
|
+
|
279
|
+
'id' => 'ad',
|
280
|
+
|
281
|
+
'name' => '広告',
|
282
|
+
|
283
|
+
'description' => 'サイドバーに表示する広告を指定。',
|
284
|
+
|
285
|
+
'before_widget' => '<aside id="%1$s" class="myad mymenu widget %2$s">',
|
286
|
+
|
287
|
+
'after_widget' => '</aside>',
|
288
|
+
|
289
|
+
'before_title' => '<h2 class="widgettitle">',
|
290
|
+
|
291
|
+
'after_title' => '</h2>'
|
292
|
+
|
293
|
+
) );
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
register_sidebars( 2, array(
|
298
|
+
|
299
|
+
'name' => __( 'Side Widget %d' ),
|
300
|
+
|
301
|
+
'id' => 'side-widget',
|
302
|
+
|
303
|
+
'before_widget' => '<li class="widget-container">',
|
304
|
+
|
305
|
+
'after_widget' => '</li>',
|
306
|
+
|
307
|
+
'before_title' => '<h3>',
|
308
|
+
|
309
|
+
'after_title' => '</h3>',
|
310
|
+
|
311
|
+
) );
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
// 検索フォーム
|
318
|
+
|
319
|
+
add_theme_support( 'html5', array('search-form') );
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
//「コメントを急いで投稿しすぎているようです。」の解除
|
324
|
+
|
325
|
+
remove_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
//srcset削除
|
332
|
+
|
333
|
+
add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
//画像挿入時の添付ファイルのページの選択肢を消す
|
340
|
+
|
341
|
+
function media_script_buffer_start() {
|
342
|
+
|
343
|
+
ob_start();
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
add_action( 'post-upload-ui', 'media_script_buffer_start' );
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
function media_script_buffer_get() {
|
352
|
+
|
353
|
+
$scripts = ob_get_clean();
|
354
|
+
|
355
|
+
$scripts = preg_replace( '#<option value="post">.*?</option>#s', '', $scripts );
|
356
|
+
|
357
|
+
echo $scripts;
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
add_action( 'print_media_templates', 'media_script_buffer_get' );
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
//attachment_id=ページに404を返す
|
366
|
+
|
367
|
+
add_action( 'template_redirect', 'gs_attachment_template_redirect' );
|
368
|
+
|
369
|
+
function gs_attachment_template_redirect() {
|
370
|
+
|
371
|
+
if ( is_attachment() ) { // 添付ファイルの個別ページなら
|
372
|
+
|
373
|
+
global $wp_query;
|
374
|
+
|
375
|
+
$wp_query->set_404();
|
376
|
+
|
377
|
+
status_header(404);
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
//hetnryを削除する
|
386
|
+
|
387
|
+
function remove_hentry( $classes ) {
|
388
|
+
|
389
|
+
$classes = array_diff($classes, array('hentry'));
|
390
|
+
|
391
|
+
return $classes;
|
392
|
+
|
393
|
+
}
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
add_filter('post_class', 'remove_hentry');
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
//固定ページにカテゴリーを出す
|
404
|
+
|
405
|
+
add_action('init','add_categories_for_pages');
|
406
|
+
|
407
|
+
function add_categories_for_pages(){
|
408
|
+
|
409
|
+
register_taxonomy_for_object_type('category', 'page');
|
410
|
+
|
411
|
+
}
|
412
|
+
|
413
|
+
add_action( 'pre_get_posts', 'nobita_merge_page_categories_at_category_archive' );
|
414
|
+
|
415
|
+
function nobita_merge_page_categories_at_category_archive( $query ) {
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
if ( $query->is_category== true && $query->is_main_query() ) {
|
420
|
+
|
421
|
+
$query->set('post_type', array( 'post', 'page', 'nav_menu_item'));
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
}
|
426
|
+
|
427
|
+
```
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
```comments.php
|
432
|
+
|
433
|
+
<div id="comment_area">
|
434
|
+
|
435
|
+
<div class="comment_post">
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
<?php $args = array(
|
440
|
+
|
441
|
+
'title_reply' => '口コミを投稿する',
|
442
|
+
|
443
|
+
'label_submit' => '口コミを送信する',
|
444
|
+
|
445
|
+
'fields' => array(
|
446
|
+
|
447
|
+
'author' => '<p class="comment-form-author">' .
|
448
|
+
|
449
|
+
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' placeholder="*お名前" /></p>',
|
450
|
+
|
451
|
+
),
|
452
|
+
|
453
|
+
'comment_field' => '<p class="comment-form-comment">' . '<textarea id="comment" name="comment" cols="50" rows="6" aria-required="true"' . $aria_req . ' placeholder="*口コミの内容" /></textarea></p>',
|
454
|
+
|
455
|
+
);
|
456
|
+
|
457
|
+
comment_form( $args ); ?>
|
458
|
+
|
459
|
+
</div>
|
460
|
+
|
461
|
+
<div class="posted_comments">
|
462
|
+
|
463
|
+
<?php if(have_comments()): ?>
|
464
|
+
|
465
|
+
<h3 id="comments">投稿された口コミ</h3>
|
466
|
+
|
467
|
+
<div class="comments-list">
|
468
|
+
|
469
|
+
<?php $comments_per_page = 10;
|
470
|
+
|
471
|
+
$comments = get_comments( array( 'status' => 'approve' ) );
|
472
|
+
|
473
|
+
?>
|
474
|
+
|
475
|
+
<?php wp_list_comments( array (
|
476
|
+
|
477
|
+
'per_page' => $comments_per_page,
|
478
|
+
|
479
|
+
'reverse_top_level' => false
|
480
|
+
|
481
|
+
), $comments ); ?>
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
</div>
|
490
|
+
|
491
|
+
<?php endif; ?>
|
492
|
+
|
493
|
+
</div>
|
494
|
+
|
495
|
+
</div>
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
<?php if(get_comment_pages_count() > 1) : ?>
|
502
|
+
|
503
|
+
<div>
|
504
|
+
|
505
|
+
<?php previous_comments_link('前のコメント'); ?>
|
506
|
+
|
507
|
+
<?php next_comments_link('次のコメント'); ?>
|
508
|
+
|
509
|
+
</div>
|
510
|
+
|
511
|
+
<?php endif; ?>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
```
|