Skip to content

Commit

Permalink
Merge pull request #59 from ryanwelcher/feature/sort-by-comment-count
Browse files Browse the repository at this point in the history
Add sorting by Comment Count
  • Loading branch information
ryanwelcher authored Jun 4, 2024
2 parents e3c608b + 97ebf75 commit a9cc21f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions includes/query-loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function add_more_sort_by( $query_params ) {
$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;
}

Expand Down
20 changes: 12 additions & 8 deletions src/components/post-order-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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' ),
Expand All @@ -54,16 +58,16 @@ export const PostOrderControls = ( { attributes, setAttributes } ) => {
value: 'meta_value_num',
},
{
label: __( 'Random', 'advanced-query-loop' ),
value: 'rand',
label: __( 'Post ID', 'advanced-query-loop' ),
value: 'id',
},
{
label: __( 'Menu Order', 'advanced-query-loop' ),
value: 'menu_order',
label: __( 'Random', 'advanced-query-loop' ),
value: 'rand',
},
{
label: __( 'Post ID', 'advanced-query-loop' ),
value: 'id',
label: __( 'Title', 'advanced-query-loop' ),
value: 'title',
},
] }
onChange={ ( newOrderBy ) => {
Expand Down

0 comments on commit a9cc21f

Please sign in to comment.