質問編集履歴
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -63,3 +63,41 @@
|
|
63
63
|
}
|
64
64
|
|
65
65
|
```
|
66
|
+
|
67
|
+
カテゴリーの方法もあったのですが動作せず今回はカスタム投稿を利用しているので
|
68
|
+
|
69
|
+
タクソノミーとタームを絞り込む必要があるのでしょうか・・
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
function getPostThNumber() {
|
74
|
+
|
75
|
+
global $wpdb, $post;
|
76
|
+
|
77
|
+
$categoryID = get_the_terms($post->ID)[0]->term_id;
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
$number = $wpdb->get_var("
|
82
|
+
|
83
|
+
SELECT COUNT(*)
|
84
|
+
|
85
|
+
FROM $wpdb->posts INNER JOIN $wpdb->term_relationships ON $wpdb->posts.ID = $wpdb->term_relationships.object_id
|
86
|
+
|
87
|
+
WHERE post_status = 'publish'
|
88
|
+
|
89
|
+
AND post_type = 'post'
|
90
|
+
|
91
|
+
AND term_taxonomy_id = $categoryID
|
92
|
+
|
93
|
+
AND post_date <= '$post->post_date'
|
94
|
+
|
95
|
+
");
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
return $number;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
```
|