質問編集履歴

1

質問を簡素化

2018/07/01 13:03

投稿

enokiyo
enokiyo

スコア78

test CHANGED
@@ -1 +1 @@
1
- wordpress で 投稿タイプごとに検索項目対象設定したい
1
+ wordpress で 更新順かつ投稿者(ユニークで)10件取得したい
test CHANGED
@@ -1,55 +1,23 @@
1
+ get_posts で どのように指定すればいいのかわからず。
2
+
1
- posttypeごとに検索項目を設定したいです。
3
+ $posts = get_posts(array(
4
+
5
+ 'post_type' => any,
6
+
7
+ 'numberposts' => 9,
8
+
9
+ 'orderby' => 'modified',
10
+
11
+ 'order' => 'DESC'
12
+
13
+ ));
2
14
 
3
15
 
4
16
 
5
- 例えば
17
+ これだと同じ投稿者が連続投稿した場合に投稿者がならんでしまうので、
6
18
 
7
- post_movie は タイトル
8
-
9
- post_location は カスタムフィルド 場所
19
+ 更新順だけど、1度登場したユザー投稿は省くようにしたいです。
10
-
11
- post_picture は 投稿者など
12
20
 
13
21
 
14
22
 
15
- add_filterの'posts_search'を使えばいいのかなと思いましたが、postタイプごとに設定する方法がわかりませんでした。
16
-
17
-
18
-
19
- $search .= "
20
-
21
- {$wpdb->posts}.post_title LIKE '{$search_word}'
22
-
23
- OR {$wpdb->posts}.post_content LIKE '{$search_word}'
24
-
25
- OR {$wpdb->posts}.post_author IN (
26
-
27
- SELECT distinct ID
28
-
29
- FROM {$wpdb->users}
30
-
31
- WHERE display_name LIKE '{$search_word}'
32
-
33
- )
34
-
35
- OR {$wpdb->posts}.ID IN (
36
-
37
- SELECT distinct r.object_id
38
-
39
- FROM {$wpdb->term_relationships} AS r
40
-
41
- INNER JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id
42
-
43
- INNER JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id
44
-
45
- WHERE t.name LIKE '{$search_word}'
46
-
47
- OR t.slug LIKE '{$search_word}'
48
-
49
- OR tt.description LIKE '{$search_word}'
50
-
51
- )
52
-
53
- ";
54
-
55
- このあたりの書きを教えてださい。
23
+ 詳しいよろしお願いたします