質問編集履歴
4
コード追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,11 +6,9 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
『**カスタム投稿にて作成した記事のカテゴリーごとの最新記事を4件取得**』 をどこにでも差し込めるようにショートコードにて作成をしたいと考えており、
|
10
|
+
|
9
11
|
下記のようなコードを考えております。
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
12
|
|
15
13
|
```php
|
16
14
|
|
@@ -134,6 +132,22 @@
|
|
134
132
|
|
135
133
|
|
136
134
|
|
135
|
+
```php
|
136
|
+
|
137
|
+
$args = array(
|
138
|
+
|
139
|
+
'posts_per_page' => 4,
|
140
|
+
|
141
|
+
'post_type' => 'estate',
|
142
|
+
|
143
|
+
);
|
144
|
+
|
145
|
+
```
|
146
|
+
|
147
|
+
$args = array(部分を上記2行にしても全件取得されてしまいました。
|
148
|
+
|
149
|
+
|
150
|
+
|
137
151
|
|
138
152
|
|
139
153
|
前後のコードが原因なのでしょうか?
|
3
コード追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,11 +14,11 @@
|
|
14
14
|
|
15
15
|
```php
|
16
16
|
|
17
|
-
function shortcode_show_case_list_estate($atts) {
|
17
|
+
function shortcode_show_case_list_estate($atts) {
|
18
18
|
|
19
19
|
$cat = '';
|
20
20
|
|
21
|
-
if(isset($atts['cat'])) { // カテゴリ指定
|
21
|
+
if(isset($atts['cat'])) { // カテゴリ指定あるか
|
22
22
|
|
23
23
|
$cat = $atts['cat'];
|
24
24
|
|
@@ -26,13 +26,13 @@
|
|
26
26
|
|
27
27
|
$args = array(
|
28
28
|
|
29
|
+
'posts_per_page' => 4,
|
30
|
+
|
29
31
|
'post_type' => 'estate',
|
30
32
|
|
31
33
|
'post_status' => 'publish',
|
32
34
|
|
33
35
|
'has_password' => false,
|
34
|
-
|
35
|
-
'posts_per_page' => 4,
|
36
36
|
|
37
37
|
'orderby' => 'date',
|
38
38
|
|
@@ -74,7 +74,7 @@
|
|
74
74
|
|
75
75
|
|
76
76
|
|
77
|
-
<div class="col-xs-12 text-center"><h3 class="text-center">その他の情報はこちら</h3></div>';
|
77
|
+
<div class="col-xs-12 text-center"><h3 class="text-center">その他の土地情報はこちら</h3></div>';
|
78
78
|
|
79
79
|
foreach($posts as $post) : setup_postdata($post);
|
80
80
|
|
@@ -86,9 +86,41 @@
|
|
86
86
|
|
87
87
|
}
|
88
88
|
|
89
|
+
|
89
90
|
|
91
|
+
$tg .= '<div class="col-md-3 col-xs-6"><a href="'.get_the_permalink($post->ID).'" title="'.get_the_title($post->ID).'">';
|
90
92
|
|
93
|
+
$tg .= '<div class="post-list__item__thumb">';
|
94
|
+
|
95
|
+
$tg .= get_the_post_thumbnail($post->ID, 'case-thumb', array( 'alt' => $term_name . 'の事例')).'<div class="post-list__item__hover"><span class="post-list__item__view">Detail</span></div>';
|
96
|
+
|
97
|
+
$tg .= '</div>';
|
98
|
+
|
99
|
+
$tg .= '<div class="post-list__item__title">'.get_field('address', $post->ID).'</div>';
|
100
|
+
|
101
|
+
$tg .= '</a></div>';
|
102
|
+
|
103
|
+
endforeach; wp_reset_postdata();
|
104
|
+
|
105
|
+
$tg .= '</div><div class="row"><div class="col-md-4 col-md-offset-4"><nav>
|
106
|
+
|
107
|
+
<div class="pager">
|
108
|
+
|
109
|
+
<li class="list"><a href="/estate">MORE</a></li>
|
110
|
+
|
111
|
+
</div></div>
|
112
|
+
|
113
|
+
</nav></div>';
|
114
|
+
|
91
|
-
|
115
|
+
return $tg;
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
return '';
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
add_shortcode('estate_list', 'shortcode_show_case_list_estate');
|
92
124
|
|
93
125
|
```
|
94
126
|
|
2
'numberposts' => 4,を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,7 +92,17 @@
|
|
92
92
|
|
93
93
|
```
|
94
94
|
|
95
|
-
|
95
|
+
```php
|
96
|
+
|
97
|
+
'numberposts' => 4,
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
こちらも試してみましたが、全件(6件中6件とも)取得されてしまいました。
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
96
106
|
|
97
107
|
前後のコードが原因なのでしょうか?
|
98
108
|
|
1
以下略を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -92,7 +92,7 @@
|
|
92
92
|
|
93
93
|
```
|
94
94
|
|
95
|
-
|
95
|
+
|
96
96
|
|
97
97
|
前後のコードが原因なのでしょうか?
|
98
98
|
|