質問編集履歴
1
表示させたいコンテンツの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
|
11
11
|
```
|
12
12
|
検索条件にヒットした募集はありませんでした。と表示されており、検索ページをどのように作成すればいいのかアドバイスをお願いいたします。
|
13
|
+
front.page.phpに表示しているコンテンツを検索ページにも表示したいです。
|
13
14
|
```
|
14
15
|
|
15
16
|
### 該当のソースコード
|
@@ -69,3 +70,39 @@
|
|
69
70
|
<?php endif; ?>
|
70
71
|
```
|
71
72
|
|
73
|
+
### search.phpに表示したいコンテンツ
|
74
|
+
```ここに言語名を入力
|
75
|
+
$categories = [];// カテゴリーIDをキーにしたカテゴリー配列を生成
|
76
|
+
foreach (get_categories() as $category) {//配列の要素のある分だけ繰り返し処理を行う
|
77
|
+
$categories[$category->cat_ID] = $category;// カテゴリーidの取得
|
78
|
+
}
|
79
|
+
function set_other_data($post)
|
80
|
+
{
|
81
|
+
// アイキャッチIDを取得
|
82
|
+
$post_thumbnail_id = get_post_thumbnail_id($post);
|
83
|
+
// アイキャッチ画像の確認
|
84
|
+
if ($post_thumbnail_id) {
|
85
|
+
// 存在する
|
86
|
+
$image_src = wp_get_attachment_image_src($post_thumbnail_id);
|
87
|
+
// サムネイルの画像URLを設定
|
88
|
+
$post->thumbnail = $image_src[0];
|
89
|
+
} else {
|
90
|
+
// 存在しない
|
91
|
+
$post->thumbnail = 'noimage.jpg';
|
92
|
+
}
|
93
|
+
// カテゴリーIDを取得
|
94
|
+
$post->categories = wp_get_post_categories($post->ID);
|
95
|
+
// コメントテキスト
|
96
|
+
if (0 == $post->comment_count) {
|
97
|
+
// コメントなし
|
98
|
+
$post->comments = __('No Comments');
|
99
|
+
} else {
|
100
|
+
// コメントあり
|
101
|
+
$post->comments = $post->comment_count.'件のコメント';
|
102
|
+
}
|
103
|
+
// コメントリンク
|
104
|
+
$post->comments_link = get_comments_link($post->ID);
|
105
|
+
}
|
106
|
+
```
|
107
|
+
|
108
|
+
|