Add ordering by words
This commit is contained in:
parent
424321a313
commit
a1a32fbe2c
@ -70,6 +70,12 @@ foreach ( $meta_query_stack as $part ) {
|
|||||||
$query_args['meta_query'][] = $part;
|
$query_args['meta_query'][] = $part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Order by words?
|
||||||
|
if ( $orderby === 'words' ) {
|
||||||
|
$query_args['orderby'] = 'meta_value_num modified';
|
||||||
|
$query_args['meta_key'] = '_word_count';
|
||||||
|
}
|
||||||
|
|
||||||
// Append date query (if any)
|
// Append date query (if any)
|
||||||
$query_args = fictioneer_append_date_query( $query_args, $ago, $orderby );
|
$query_args = fictioneer_append_date_query( $query_args, $ago, $orderby );
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function fictioneer_allowed_orderby() {
|
function fictioneer_allowed_orderby() {
|
||||||
$defaults = ['modified', 'date', 'title', 'rand', 'name', 'ID', 'comment_count', 'type', 'post__in', 'author'];
|
$defaults = ['modified', 'date', 'title', 'rand', 'name', 'ID', 'comment_count', 'type', 'post__in', 'author', 'words'];
|
||||||
|
|
||||||
return apply_filters( 'fictioneer_filter_allowed_orderby', $defaults );
|
return apply_filters( 'fictioneer_filter_allowed_orderby', $defaults );
|
||||||
}
|
}
|
||||||
|
@ -488,19 +488,26 @@ function fictioneer_sort_order_filter_interface( $args ) {
|
|||||||
// Order menu options
|
// Order menu options
|
||||||
$orderby_menu = array(
|
$orderby_menu = array(
|
||||||
'modified' => array(
|
'modified' => array(
|
||||||
'label' => __( 'Updated', 'fictioneer' ),
|
'label' => _x( 'Updated', 'Sort and filter option.', 'fictioneer' ),
|
||||||
'url' => add_query_arg( array( 'orderby' => 'modified' ), $current_url ) . '#sof'
|
'url' => add_query_arg( array( 'orderby' => 'modified' ), $current_url ) . '#sof'
|
||||||
),
|
),
|
||||||
'date' => array(
|
'date' => array(
|
||||||
'label' => __( 'Published', 'fictioneer' ),
|
'label' => _x( 'Published', 'Sort and filter option.', 'fictioneer' ),
|
||||||
'url' => add_query_arg( array( 'orderby' => 'date' ), $current_url ) . '#sof'
|
'url' => add_query_arg( array( 'orderby' => 'date' ), $current_url ) . '#sof'
|
||||||
),
|
),
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'label' => __( 'By Title', 'fictioneer' ),
|
'label' => _x( 'Title', 'Sort and filter option.', 'fictioneer' ),
|
||||||
'url' => add_query_arg( array( 'orderby' => 'title' ), $current_url ) . '#sof'
|
'url' => add_query_arg( array( 'orderby' => 'title' ), $current_url ) . '#sof'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( ! is_archive() ) {
|
||||||
|
$orderby_menu['words'] = array(
|
||||||
|
'label' => _x( 'Words', 'Sort and filter option.', 'fictioneer' ),
|
||||||
|
'url' => add_query_arg( array( 'orderby' => 'words' ), $current_url ) . '#sof'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Filter orderby options
|
// Filter orderby options
|
||||||
$orderby_menu = apply_filters( 'fictioneer_filter_sof_orderby_options', $orderby_menu, $current_url, $args );
|
$orderby_menu = apply_filters( 'fictioneer_filter_sof_orderby_options', $orderby_menu, $current_url, $args );
|
||||||
|
|
||||||
|
@ -71,6 +71,12 @@ foreach ( $meta_query_stack as $part ) {
|
|||||||
$query_args['meta_query'][] = $part;
|
$query_args['meta_query'][] = $part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Order by words?
|
||||||
|
if ( $orderby === 'words' ) {
|
||||||
|
$query_args['orderby'] = 'meta_value_num modified';
|
||||||
|
$query_args['meta_key'] = 'fictioneer_story_total_word_count';
|
||||||
|
}
|
||||||
|
|
||||||
// Order by latest chapter update timestamp?
|
// Order by latest chapter update timestamp?
|
||||||
if ( FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER && $orderby === 'modified' ) {
|
if ( FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER && $orderby === 'modified' ) {
|
||||||
$query_args['orderby'] = 'meta_value modified';
|
$query_args['orderby'] = 'meta_value modified';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user