Allow stories to be ordered by latest chapter update
This commit is contained in:
parent
7301ee4484
commit
5d442f5d54
@ -833,7 +833,7 @@ function fictioneer_clause_sticky_stories( $clauses, $wp_query ) {
|
||||
// Setup
|
||||
$vars = $wp_query->query_vars;
|
||||
$allowed_queries = ['stories_list', 'latest_stories', 'latest_stories_compact', 'author_stories'];
|
||||
$allowed_orderby = ['date', 'modified', 'title'];
|
||||
$allowed_orderby = ['date', 'modified', 'title', 'meta_value', 'meta_value date', 'meta_value modified', 'meta_value title'];
|
||||
|
||||
// Return if wrong query
|
||||
if (
|
||||
@ -923,3 +923,4 @@ define( 'CONSTANT_NAME', value );
|
||||
| FICTIONEER_ENABLE_STORY_DATA_META_CACHE | boolean | Whether to "cache" story data in a meta field. Default `true`.
|
||||
| FICTIONEER_ENABLE_FRONTEND_ACF | boolean | Whether to load ACF on the frontend. Default `false`.
|
||||
| FICTIONEER_ENABLE_MENU_TRANSIENTS | boolean | Whether to cache nav menus as Transients. Default `true`.
|
||||
| FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER | boolean | Whether to order updated stories based on the latest chapter added, excluding stories without chapters. Default `false`.
|
||||
|
@ -351,6 +351,11 @@ if ( ! defined( 'FICTIONEER_ENABLE_MENU_TRANSIENTS' ) ) {
|
||||
define( 'FICTIONEER_ENABLE_MENU_TRANSIENTS', true );
|
||||
}
|
||||
|
||||
// Boolean: Order stories by last updated chapter timestamp
|
||||
if ( ! defined( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER' ) ) {
|
||||
define( 'FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER', false );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// FAST REQUESTS
|
||||
//
|
||||
|
@ -229,7 +229,7 @@ function fictioneer_clause_sticky_stories( $clauses, $wp_query ) {
|
||||
// Setup
|
||||
$vars = $wp_query->query_vars;
|
||||
$allowed_queries = ['stories_list', 'latest_stories', 'latest_stories_compact', 'author_stories'];
|
||||
$allowed_orderby = ['date', 'modified', 'title'];
|
||||
$allowed_orderby = ['date', 'modified', 'title', 'meta_value', 'meta_value date', 'meta_value modified', 'meta_value title'];
|
||||
|
||||
// Return if wrong query
|
||||
if (
|
||||
|
@ -47,6 +47,12 @@ $query_args = array (
|
||||
)
|
||||
);
|
||||
|
||||
// Order by latest chapter update timestamp?
|
||||
if ( FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER && $orderby === 'modified' ) {
|
||||
$query_args['orderby'] = 'meta_value modified';
|
||||
$query_args['meta_key'] = 'fictioneer_chapters_added';
|
||||
}
|
||||
|
||||
// Append date query (if any)
|
||||
$query_args = fictioneer_append_date_query( $query_args, $ago, $orderby );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user