質問編集履歴

3

コードを修正

2024/04/12 07:23

投稿

musashidayo
musashidayo

スコア54

test CHANGED
File without changes
test CHANGED
@@ -51,7 +51,7 @@
51
51
  $comments = get_comments($args);//ここで絞り込みを完了
52
52
  $comment_ids = [];
53
53
  foreach($comments as $comment){
54
- $comment_ids[] = $comment;
54
+ $comment_ids[] = $comment->ID;
55
55
  }
56
56
  $args = array(
57
57
  'comment__in' => $comment_ids,

2

コード追記

2024/04/12 07:18

投稿

musashidayo
musashidayo

スコア54

test CHANGED
File without changes
test CHANGED
@@ -40,4 +40,24 @@
40
40
  stackoverflowでの検索->みつかりませんでした
41
41
 
42
42
  ### 補足
43
+ ***追記:一度該当のcomment_IDを元の条件で取得してから並び替えという方法しかないでしょうか?
44
+ ```php
45
+ $args = array(
46
+ 'post_id' => $post->ID,
47
+ 'number' => 10000,
48
+ 'meta_key' => 'slug_for'
49
+      'meta_value' => '特定のstring'
50
+ );
51
+ $comments = get_comments($args);//ここで絞り込みを完了
52
+ $comment_ids = [];
53
+ foreach($comments as $comment){
54
+ $comment_ids[] = $comment;
55
+ }
56
+ $args = array(
57
+ 'comment__in' => $comment_ids,
58
+ 'order' => "ASC",
59
+ 'orderby' => 'meta_value_num',
60
+ 'meta_key' => 'ave_score',
61
+ );
62
+
43
- 特になし
63
+ ```

1

コードの更新

2024/04/12 05:06

投稿

musashidayo
musashidayo

スコア54

test CHANGED
File without changes
test CHANGED
@@ -6,12 +6,13 @@
6
6
 
7
7
  ```php
8
8
  $args = array(
9
- 'post_id' => $post->ID,
9
+ 'post_id' => $post->ID,
10
- 'number' => 10000,
10
+ 'number' => 10000,
11
- 'order' => "ASC",
11
+ 'order' => "ASC",
12
- 'orderby' => 'meta_value_num',
12
+ 'orderby' => 'meta_value_num',
13
- 'meta_key' => 'ave_score',
13
+ 'meta_key' => 'ave_score',
14
- );
14
+ );
15
+ $comments = get_comments($args);
15
16
  ```
16
17
  上記は現在の絞り込み(ave_scoreに各コメントの点数が入っていてそれでソートしている部分です)
17
18
  更に加えて