admin管理员组

文章数量:1122846

I apologise deeply if this topic already been answered here in the past. I have searched for an answer and couldn't find.

The question is regarding Gutenberg, FSE editor, block theme: is it possible to customize the Query Loop to allow to order by comments number, and post visualization number? If yes, how can I do that? (right now using twenty twenty four theme).

Thank you.

I apologise deeply if this topic already been answered here in the past. I have searched for an answer and couldn't find.

The question is regarding Gutenberg, FSE editor, block theme: is it possible to customize the Query Loop to allow to order by comments number, and post visualization number? If yes, how can I do that? (right now using twenty twenty four theme).

Thank you.

Share Improve this question edited May 10, 2024 at 3:18 neoswf asked May 7, 2024 at 0:23 neoswfneoswf 1256 bronze badges 2
  • What do you mean by "post visualization number" please? – Wongjn Commented May 7, 2024 at 7:15
  • @Wongjn - I meant views number per post, but ill be fine with ordering by comments number. Any idea how can I achieve that, add this functionality to the query loop? (have edited the question) – neoswf Commented May 10, 2024 at 3:17
Add a comment  | 

1 Answer 1

Reset to default 0

You could change the query.orderBy parameter of the query block (as long as query.inherit is not true). This parameter corresponds to the orderby query var. For number of comments, you'd use the comments_count value, as per the `WP_Query::parse_query documentation.

To add this value, you'd need to be in the code editor (not visual editor) of the block editor and have these as in the block comment opener for the core/query block:

<!-- wp:query {"query":{ … "orderBy":"comment_count", … "inherit":false}, … } -->

本文标签: How to make FSE39s query loop to order by comments number