From 1afc37c586e3645d9016d2bd3ad3196864a53c76 Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Fri, 10 May 2024 15:44:49 -0400 Subject: [PATCH 1/2] Add comment_count to the Order By options. --- includes/query-loop.php | 1 + src/components/post-order-controls.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/includes/query-loop.php b/includes/query-loop.php index d98e35b..1f70b7a 100644 --- a/includes/query-loop.php +++ b/includes/query-loop.php @@ -255,6 +255,7 @@ function add_more_sort_by( $query_params, $post_type ) { $query_params['orderby']['enum'][] = 'meta_value'; $query_params['orderby']['enum'][] = 'meta_value_num'; $query_params['orderby']['enum'][] = 'rand'; + $query_params['orderby']['enum'][] = 'comment_count'; return $query_params; } diff --git a/src/components/post-order-controls.js b/src/components/post-order-controls.js index 967460b..e0e473b 100644 --- a/src/components/post-order-controls.js +++ b/src/components/post-order-controls.js @@ -65,6 +65,10 @@ export const PostOrderControls = ( { attributes, setAttributes } ) => { label: __( 'Post ID', 'advanced-query-loop' ), value: 'id', }, + { + label: __( 'Comment Count', 'advanced-query-loop' ), + value: 'comment_count', + }, ] } onChange={ ( newOrderBy ) => { setAttributes( { From 97ebf754c141c5caa472d439c72e10e9a6a85bdf Mon Sep 17 00:00:00 2001 From: Ryan Welcher Date: Fri, 10 May 2024 15:45:10 -0400 Subject: [PATCH 2/2] Sort options alphabetically --- src/components/post-order-controls.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/components/post-order-controls.js b/src/components/post-order-controls.js index e0e473b..f8df9ac 100644 --- a/src/components/post-order-controls.js +++ b/src/components/post-order-controls.js @@ -30,6 +30,10 @@ export const PostOrderControls = ( { attributes, setAttributes } ) => { label: __( 'Author', 'advanced-query-loop' ), value: 'author', }, + { + label: __( 'Comment Count', 'advanced-query-loop' ), + value: 'comment_count', + }, { label: __( 'Date', 'advanced-query-loop' ), value: 'date', @@ -42,8 +46,8 @@ export const PostOrderControls = ( { attributes, setAttributes } ) => { value: 'modified', }, { - label: __( 'Title', 'advanced-query-loop' ), - value: 'title', + label: __( 'Menu Order', 'advanced-query-loop' ), + value: 'menu_order', }, { label: __( 'Meta Value', 'advanced-query-loop' ), @@ -53,21 +57,17 @@ export const PostOrderControls = ( { attributes, setAttributes } ) => { label: __( 'Meta Value Num', 'advanced-query-loop' ), value: 'meta_value_num', }, - { - label: __( 'Random', 'advanced-query-loop' ), - value: 'rand', - }, - { - label: __( 'Menu Order', 'advanced-query-loop' ), - value: 'menu_order', - }, { label: __( 'Post ID', 'advanced-query-loop' ), value: 'id', }, { - label: __( 'Comment Count', 'advanced-query-loop' ), - value: 'comment_count', + label: __( 'Random', 'advanced-query-loop' ), + value: 'rand', + }, + { + label: __( 'Title', 'advanced-query-loop' ), + value: 'title', }, ] } onChange={ ( newOrderBy ) => {