Skip to content

Commit

Permalink
Fix handpicked posts should orderby include
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyc committed Aug 23, 2024
1 parent f61fee0 commit a5e4805
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion web/app/themes/gds/app/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
*/
add_filter('query_loop_block_query_vars', function (array $query, WP_Block $block) {
if (! empty($block->context['query']['include'])) {
$query['post__in'] = $block->context['query']['include'];
$query['include'] = $block->context['query']['include'];
$query['orderby'] = 'include';
$query['order'] = 'DESC';
}

return $query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ function HandPickedPostsControl({setAttributes, attributes}) {
return acc;
}, new Set());

updateQuery({include: Array.from(newPostsSet)});
updateQuery({
include: Array.from(newPostsSet),
orderby: 'include',
order: 'desc'
});
},
[postsMap],
);
Expand Down Expand Up @@ -82,8 +86,8 @@ function HandPickedPostsControl({setAttributes, attributes}) {
<ToolsPanelItem
label={__('Hand-picked posts', 'gds')}
hasValue={() => !!selectedPostIds?.length}
onDeselect={() => updateQuery({include: []})}
resetAllFilter={() => updateQuery({include: []})}
onDeselect={() => updateQuery({include: [], orderby: 'date', order: 'desc'})}
resetAllFilter={() => updateQuery({include: [], orderby: 'date', order: 'desc'})}
isShownByDefault={true}
>
<FormTokenField
Expand Down

0 comments on commit a5e4805

Please sign in to comment.