質問編集履歴
1
コード編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,7 +8,211 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
|
11
|
+
```ここに言語を入力
|
12
|
+
|
13
|
+
if( !function_exists('bzb_breadcrumb') ){
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
function bzb_breadcrumb(){
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
global $post;
|
22
|
+
|
23
|
+
// ポストタイプを取得
|
24
|
+
|
25
|
+
$post_type = get_post_type( $post );
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
$bc = '<ol class="breadcrumb clearfix">';
|
30
|
+
|
31
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.home_url().'" itemprop="url"><i class="fa fa-home"></i> <span itemprop="title">ホーム</span></a> / </li>';
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
if( is_home() ){
|
36
|
+
|
37
|
+
// メインページ
|
38
|
+
|
39
|
+
$bc .= '<li><i class="fa fa-list-alt"></i> 最新記事一覧</li>';
|
40
|
+
|
41
|
+
}elseif( is_search() ){
|
42
|
+
|
43
|
+
// 検索結果ページ
|
44
|
+
|
45
|
+
$bc .= '<li><i class="fa fa-search"></i> 「'.get_search_query().'」の検索結果</li>';
|
46
|
+
|
47
|
+
}elseif( is_404() ){
|
48
|
+
|
49
|
+
// 404ページ
|
50
|
+
|
51
|
+
$bc .= '<li><i class="fa fa-question-circle"></i> ページが見つかりませんでした</li>';
|
52
|
+
|
53
|
+
}elseif( is_date() ){
|
54
|
+
|
55
|
+
// 日付別一覧ページ
|
56
|
+
|
57
|
+
$bc .= '<li><i class="fa fa-clock-o"></i> ';
|
58
|
+
|
59
|
+
if( is_day() ){
|
60
|
+
|
61
|
+
$bc .= get_query_var( 'year' ).'年 ';
|
62
|
+
|
63
|
+
$bc .= get_query_var( 'monthnum' ).'月 ';
|
64
|
+
|
65
|
+
$bc .= get_query_var( 'day' ).'日';
|
66
|
+
|
67
|
+
}elseif( is_month() ){
|
68
|
+
|
69
|
+
$bc .= get_query_var( 'year' ).'年 ';
|
70
|
+
|
71
|
+
$bc .= get_query_var( 'monthnum' ).'月 ';
|
72
|
+
|
73
|
+
}elseif( is_year() ){
|
74
|
+
|
75
|
+
$bc .= get_query_var( 'year' ).'年 ';
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
$bc .= '</li>';
|
80
|
+
|
81
|
+
}elseif( is_post_type_archive() ){
|
82
|
+
|
83
|
+
// カスタムポストアーカイブ
|
84
|
+
|
85
|
+
$bc .= '<li><i class="fa fa-folder"></i> '.post_type_archive_title('', false).'</li>';
|
86
|
+
|
87
|
+
}elseif( is_category() ){
|
88
|
+
|
89
|
+
// カテゴリーページ
|
90
|
+
|
91
|
+
$cat = get_queried_object();
|
92
|
+
|
93
|
+
if( $cat -> parent != 0 ){
|
94
|
+
|
95
|
+
$ancs = array_reverse(get_ancestors( $cat->cat_ID, 'category' ));
|
96
|
+
|
97
|
+
foreach( $ancs as $anc ){
|
98
|
+
|
99
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_category_link($anc).'" itemprop="url"><i class="fa fa-folder"></i> <span itemprop="title">'.get_cat_name($anc).'</span></a> / </li>';
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
$bc .= '<li><i class="fa fa-folder"></i> '.$cat->cat_name.'</li>';
|
106
|
+
|
107
|
+
}elseif( is_tag() ){
|
108
|
+
|
109
|
+
// タグページ
|
110
|
+
|
111
|
+
$bc .= '<li><i class="fa fa-tag"></i> '.single_tag_title("",false).'</li>';
|
112
|
+
|
113
|
+
}elseif( is_author() ){
|
114
|
+
|
115
|
+
// 著者ページ
|
116
|
+
|
117
|
+
$bc .= '<li><i class="fa fa-user"></i> '.get_the_author_meta('display_name').'</li>';
|
118
|
+
|
119
|
+
}elseif( is_attachment() ){
|
120
|
+
|
121
|
+
// 添付ファイルページ
|
122
|
+
|
123
|
+
if( $post->post_parent != 0 ){
|
124
|
+
|
125
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_permalink( $post->post_parent ).'" itemprop="url"><i class="fa fa-file-text"></i> <span itemprop="title">'.get_the_title( $post->post_parent ).'</span></a> / </li>';
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
$bc .= '<li><i class="fa fa-picture-o"></i> '.$post->post_title.'</li>';
|
130
|
+
|
131
|
+
}elseif( is_singular('post') ){
|
132
|
+
|
133
|
+
$cats = get_the_category( $post->ID );
|
134
|
+
|
135
|
+
$cat = $cats[0];
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
if( $cat->parent != 0 ){
|
140
|
+
|
141
|
+
$ancs = array_reverse(get_ancestors( $cat->cat_ID, 'category' ));
|
142
|
+
|
143
|
+
foreach( $ancs as $anc ){
|
144
|
+
|
145
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_category_link( $anc ).'" itemprop="url"><i class="fa fa-folder"></i> <span itemprop="title">'.get_cat_name($anc).'</span></a> / </li>';
|
146
|
+
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_category_link( $cat->cat_ID ).'" itemprop="url"><i class="fa fa-folder"></i> <span itemprop="title">'.$cat->cat_name.'</span></a> / </li>';
|
152
|
+
|
153
|
+
$bc .= '<li><i class="fa fa-file-text"></i> '.$post->post_title.'</li>';
|
154
|
+
|
155
|
+
}elseif( is_singular('page') ){
|
156
|
+
|
157
|
+
// 固定ページ
|
158
|
+
|
159
|
+
if( $post->post_parent != 0 ){
|
160
|
+
|
161
|
+
$ancs = array_reverse( $post->ancestors );
|
162
|
+
|
163
|
+
foreach( $ancs as $anc ){
|
164
|
+
|
165
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_permalink( $anc ).'" itemprop="url"><i class="fa fa-file"></i> <span itemprop="title">'.get_the_title($anc).'</span></a> /';
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
$bc .= '<li><i class="fa fa-file"></i> '.$post->post_title.'</li>';
|
172
|
+
|
173
|
+
}elseif( is_singular( $post_type ) ){
|
174
|
+
|
175
|
+
// カスタムポスト記事ページ
|
176
|
+
|
177
|
+
$obj = get_post_type_object($post_type);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
if( $obj->has_archive == true ){
|
182
|
+
|
183
|
+
$bc .= '<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Breadcrumb"><a href="'.get_post_type_archive_link($post_type).'" itemprop="url"><i class="fa fa-pencil-square-o"></i> <span itemprop="title">'.get_post_type_object( $post_type )->label.'</span></a> / </li>';
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
$bc .= '<li><i class="fa fa-file"></i> '.$post->post_title.'</li>';
|
188
|
+
|
189
|
+
}else{
|
190
|
+
|
191
|
+
// その他のページ
|
192
|
+
|
193
|
+
$bc .= '<li><i class="fa fa-file"></i> '.$post->post_title.'</li>';
|
194
|
+
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
$bc .= '</ol>';
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
echo $bc;
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
12
216
|
|
13
217
|
|
14
218
|
|