Update story queries and shortcodes

This commit is contained in:
Tetrakern 2023-09-16 13:10:52 +02:00
parent c6d2fe5081
commit 977609a6f8
4 changed files with 70 additions and 37 deletions

View File

@ -855,28 +855,40 @@ Filters the intermediate output arrays in the `_latest-stories.php` and `_latest
Filters the query arguments in the `fictioneer_latest_stories` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters.
**$query_args:**
* $fictioneer_query_name (string) `'latest_stories'` or `'latest_stories_compact'`
* $post_type (string) `'fcn_story'`
* $post_status (string) `'publish'`
* $author_name (string|null) `$args['author']`
* $post__in (array) `$args['post_ids']`
* $order (string) `$args['order']`
* $orderby (array)
* $fictioneer_story_sticky `'DESC'`
* `$args['orderby']` `$args['order']`
* $posts_per_page (int) `$args['count']`
* $meta_key (string) `'fictioneer_story_sticky'`
* $meta_query (array)
* $relation (string) `'OR'`
* (array)
* $key `'fictioneer_story_hidden'`
* $value `'0'`
* (array)
* $key `'fictioneer_story_hidden'`
* $compare `'NOT EXISTS'`
* $author_name (string|null) `$args['author']`
* $category__not_in (array|null) `$args['excluded_cats']`
* $tag__not_in (array|null) `$args['excluded_tags']`
* $meta_key (string) `'fictioneer_story_sticky'`
* $orderby (string) `'meta_value ' . $args['orderby']`
* $order (string) `$args['order']`
* $posts_per_page (int) `$args['count']`
* $tax_query (array|null) `fictioneer_get_shortcode_tax_query( $args )`
* $no_found_rows (boolean) `true`
**$args:**
* $author (boolean|string) The author provided by the shortcode. Default `false`.
* $count (int) The number of posts provided by the shortcode. Default `1`.
* $orderby (string) Optional. Default `'date'`.
* $order (string) Optional. Default `'DESC'`.
* $post_ids (\[string]) Array of post IDs. Default empty.
* $ignore_protected (boolean) Optional. Whether to ignore protected posts. Default `false`.
* $excluded_cats (\[string]) Array of category IDs to exclude. Default empty.
* $excluded_tags (\[string]) Array of tag IDs to exclude. Default empty.
* $taxonomies (\[array]) Array of taxonomy arrays (names). Default empty.
* $count (int) Maximum number of posts. Default `-1`.
* $author (boolean|string) Limit posts to a specific author. Default `false`.
* $order (string) Order argument. Default `'DESC'`.
* $orderby (string) Orderby argument. Default `'date'`.
* $post_ids (array) Limit posts to specific post IDs. Default empty.
* $excluded_tags (array) Exclude specific tag names. Default empty.
* $excluded_cats (array) Exclude specific category names. Default empty.
* $ignore_protected (boolean) Whether to ignore protected posts. Default `false`.
* $taxonomies (array) Array of arrays of required taxonomy names. Default empty.
* $relation (string) Relationship between taxonomies. Default `'AND'`.
* $classes (string) String of additional CSS classes. Default empty.
@ -1062,13 +1074,25 @@ Filters the arguments passed to the `partials/_card-story` template part in the
Filters the arguments to query the stories in the `stories.php` template.
**$query_args:**
* $fictioneer_query_name (string) `'stories_list'`
* $post_type (string) `'fcn_story'`
* $post_status (string) `'publish'`
* $meta_key (string) `'fictioneer_story_sticky'`
* $orderby (string) Current orderby or `'meta_value modified'`.
* $order (string) Current order or `desc`.
* $paged (int) Current page if paginated or `1`.
* $order (string) `'DESC'` or `'ASC'`
* $orderby (array)
* $fictioneer_story_sticky `'DESC'`
* `$args['orderby']` `$args['order']`
* $paged (int) Current page number or `1`.
* $posts_per_page (int) `get_option( 'posts_per_page' )`
* $meta_key (string) `'fictioneer_story_sticky'`
* $meta_query (array)
* $relation (string) `'OR'`
* (array)
* $key `'fictioneer_story_hidden'`
* $value `'0'`
* (array)
* $key `'fictioneer_story_hidden'`
* $compare `'NOT EXISTS'`
* $update_post_term_cache `! get_option( 'fictioneer_hide_taxonomies_on_story_cards' )`
**Parameters:**
* $post_id (int) Current post ID.

View File

@ -36,8 +36,8 @@ $query_args = array(
'post_type' => 'fcn_story',
'post_status' => 'publish',
'post__in' => $args['post_ids'], // May be empty!
'order' => $args['order'],
'orderby' => $args['orderby'],
'order' => $args['order'] ?? 'DESC',
'posts_per_page' => $args['count'],
'meta_query' => array(
'relation' => 'OR',
@ -48,14 +48,18 @@ $query_args = array(
array(
'key' => 'fictioneer_story_hidden',
'compare' => 'NOT EXISTS'
),
)
),
'no_found_rows' => true
);
if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
$query_args['meta_key'] = 'fictioneer_story_sticky';
$query_args['orderby'] = 'meta_value ' . $query_args['orderby'];
$query_args['orderby'] = array(
'fictioneer_story_sticky' => 'DESC',
$args['orderby'] => $args['order']
);
}
// Parameter for author?

View File

@ -33,8 +33,8 @@ $query_args = array(
'post_type' => 'fcn_story',
'post_status' => 'publish',
'post__in' => $args['post_ids'], // May be empty!
'order' => $args['order'],
'orderby' => $args['orderby'],
'order' => $args['order'] ?? 'DESC',
'posts_per_page' => $args['count'],
'meta_query' => array(
'relation' => 'OR',
@ -45,14 +45,18 @@ $query_args = array(
array(
'key' => 'fictioneer_story_hidden',
'compare' => 'NOT EXISTS'
),
)
),
'no_found_rows' => true
);
if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
$query_args['meta_key'] = 'fictioneer_story_sticky';
$query_args['orderby'] = 'meta_value ' . $query_args['orderby'];
$query_args['orderby'] = array(
'fictioneer_story_sticky' => 'DESC',
$args['orderby'] => $args['order']
);
}
// Parameter for author?

View File

@ -31,25 +31,26 @@ $query_args = array (
'fictioneer_query_name' => 'stories_list',
'post_type' => 'fcn_story',
'post_status' => 'publish',
'orderby' => $orderby,
'order' => $order,
'orderby' => $orderby,
'paged' => $page,
'posts_per_page' => get_option( 'posts_per_page', 8 ),
'update_post_term_cache' => ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' )
'update_post_term_cache' => ! get_option( 'fictioneer_hide_taxonomies_on_story_cards' ),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'fictioneer_story_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_story_hidden',
'compare' => 'NOT EXISTS'
)
)
);
if ( FICTIONEER_ENABLE_STICKY_CARDS ) {
$query_args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'fictioneer_story_sticky',
'compare' => 'EXISTS'
),
array(
'key' => 'fictioneer_story_sticky',
'compare' => 'NOT EXISTS'
)
);
$query_args['meta_key'] = 'fictioneer_story_sticky';
$query_args['orderby'] = array(
'fictioneer_story_sticky' => 'DESC',