Skip to content

Commit

Permalink
Block theme: Switch to "newest" for front page sorting to match curre…
Browse files Browse the repository at this point in the history
…nt site
  • Loading branch information
ryelle committed Apr 11, 2024
1 parent d220635 commit f242b52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ function get_sort_options( $options ) {
$sort = 'favorite_count_desc';
}

// Show the correct filters on the front page.
if ( is_front_page() ) {
$sort = 'date_desc';
}

$label = __( 'Sort', 'wporg-patterns' );
switch ( $sort ) {
case 'date_desc':
Expand All @@ -193,12 +198,6 @@ function get_sort_options( $options ) {
break;
}

// Show the correct filters on the front page.
if ( is_front_page() ) {
$sort = 'favorite_count_desc';
$label = __( 'Popular', 'wporg-patterns' );
}

$options = array(
'date_desc' => __( 'Newest', 'wporg-patterns' ),
'date_asc' => __( 'Oldest', 'wporg-patterns' ),
Expand Down Expand Up @@ -256,7 +255,7 @@ function inject_other_filters( $key ) {
printf( '<input type="hidden" name="curation" value="core" />' );
}
if ( 'orderby' !== $key ) {
printf( '<input type="hidden" name="orderby" value="favorite_count_desc" />' );
printf( '<input type="hidden" name="orderby" value="date_desc" />' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

?>
<!-- wp:query {"queryId":0,"query":{"perPage":12,"curation":"core","pages":0,"offset":0,"postType":"wporg-pattern","order":"desc","orderBy":"favorite_count","author":"","search":"","exclude":[],"sticky":"","inherit":false},"align":"wide","layout":{"type":"default"}} -->
<!-- wp:query {"queryId":0,"query":{"perPage":12,"curation":"core","pages":0,"offset":0,"postType":"wporg-pattern","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"align":"wide","layout":{"type":"default"}} -->
<div class="wp-block-query alignwide">
<!-- wp:navigation {"menuSlug":"categories","ariaLabel":"<?php esc_attr_e( 'Category menu', 'wporg-patterns' ); ?>","overlayMenu":"never","layout":{"type":"flex","orientation":"horizontal","justifyContent":"left","flexWrap":"nowrap"},"fontSize":"small","className":"is-style-button-list"} /-->

Expand Down

0 comments on commit f242b52

Please sign in to comment.