質問編集履歴
1
forachにselect-box ・ $selected を追加し url から年4桁を抜き出すことで対応
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,25 +92,31 @@
|
|
92
92
|
|
93
93
|
|
94
94
|
|
95
|
-
if ( $arcresults ) {
|
95
|
+
if ( $arcresults ) {
|
96
96
|
|
97
|
-
|
97
|
+
$defAfter = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
98
98
|
|
99
|
-
|
99
|
+
$After = preg_replace('/[^0-9]/', '', $defAfter);
|
100
100
|
|
101
|
-
|
101
|
+
foreach ( (array) $arcresults as $arcresult ) {
|
102
102
|
|
103
|
-
|
103
|
+
$After = substr($defAfter, 29, 4); // URLから年4桁を抜き出す
|
104
104
|
|
105
|
-
|
105
|
+
$Years = $arcresult->year;
|
106
106
|
|
107
|
-
|
107
|
+
$Cnt = $arcresult->posts;
|
108
108
|
|
109
|
-
|
109
|
+
$selected = $Years === $After ? ' selected' : '';
|
110
110
|
|
111
|
-
|
111
|
+
$url = add_query_arg( array( 'meta_key' => $date_field ), get_year_link( $arcresult->year ) );
|
112
112
|
|
113
|
+
$text = sprintf( '%d', $arcresult->year ).'年';
|
114
|
+
|
115
|
+
$output .= '<option value="'.$url.'"'.$selected.'>'.$text.' ('.$Cnt.')</option>';
|
116
|
+
|
113
|
-
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
114
120
|
|
115
121
|
|
116
122
|
|