diff --git a/FILTERS.md b/FILTERS.md index 00afa4eb..aaa73196 100644 --- a/FILTERS.md +++ b/FILTERS.md @@ -955,29 +955,31 @@ Filters the query arguments in the `fictioneer_latest_updates` shortcode. The op Filters the query arguments in the `fictioneer_showcase` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters. **$query_args:** +* $fictioneer_query_name (string) – `'showcase'` * $post_type (string) – `$args['type']` * $post_status (string) – `'publish'` -* $author_name (string|null) – `$args['author']` * $post__in (array) – `$args['post_ids']` +* $order (string) – `$args['order']` +* $orderby (string) – `$args['orderby']` +* $posts_per_page (int) – `$args['count']` +* $author_name (string|null) – `$args['author']` * $category__not_in (array|null) – `$args['excluded_cats']` * $tag__not_in (array|null) – `$args['excluded_tags']` -* $orderby (string) – `$args['orderby']` -* $order (string) – `$args['order']` -* $posts_per_page (int) – `$args['count']` +* $tax_query (array|null) – `fictioneer_get_shortcode_tax_query( $args )` * $update_post_term_cache (boolean) – `false` * $no_found_rows (boolean) – `true` **$args:** * $type (string) – Either `'fcn_collection'`, `'fcn_story'`, `'fcn_chapter'`, or `'fcn_recommendation'`. -* $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'`. * $no_cap (boolean) – Whether to hide captions. Default `false`. * $classes (string) – String of additional CSS classes. Default empty. diff --git a/includes/functions/_shortcodes.php b/includes/functions/_shortcodes.php index 1aa2025f..0b806bb9 100644 --- a/includes/functions/_shortcodes.php +++ b/includes/functions/_shortcodes.php @@ -279,11 +279,10 @@ function fictioneer_shortcode_showcase( $attr ) { } // Setup - $count = max( 1, intval( $attr['count'] ?? 8 ) ); + $count = max( 1, intval( $attr['count'] ?? 9 ) ); $author = $attr['author'] ?? false; $order = $attr['order'] ?? 'DESC'; $orderby = $attr['orderby'] ?? 'date'; - $no_cap = $attr['no_cap'] ?? false; $classes = esc_attr( wp_strip_all_tags( $attr['class'] ?? '' ) ); $post_ids = fictioneer_explode_list( $attr['post_ids'] ?? '' ); $rel = strtolower( $attr['rel'] ?? 'and' ) === 'or' ? 'OR' : 'AND'; @@ -297,15 +296,15 @@ function fictioneer_shortcode_showcase( $attr ) { $args = array( 'count' => $count, 'author' => $author, - 'orderby' => $orderby, 'order' => $order, + 'orderby' => $orderby, 'post_ids' => $post_ids, 'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ), 'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ), 'ignore_protected' => filter_var( $attr['ignore_protected'] ?? 0, FILTER_VALIDATE_BOOLEAN ), 'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ), 'relation' => $rel, - 'no_cap' => $no_cap == 'true' || $no_cap == '1', + 'no_cap' => filter_var( $attr['no_cap'] ?? 0, FILTER_VALIDATE_BOOLEAN ), 'classes' => $classes ); diff --git a/partials/_showcase.php b/partials/_showcase.php index ef8943d3..942eb024 100644 --- a/partials/_showcase.php +++ b/partials/_showcase.php @@ -12,7 +12,7 @@ * @since 4.0 * * @internal $args['type'] Post type if the showcase. - * @internal $args['count'] Maximum number of items. Default 8. + * @internal $args['count'] Maximum number of items. Default 9. * @internal $args['order'] Order direction. Default 'DESC'. * @internal $args['orderby'] Order argument. Default 'date'. * @internal $args['author'] Author provided by the shortcode. @@ -33,18 +33,21 @@ defined( 'ABSPATH' ) OR exit; // Prepare query $query_args = array ( + 'fictioneer_query_name' => 'showcase', 'post_type' => $args['type'], 'post_status' => 'publish', 'post__in' => $args['post_ids'], // May be empty! - 'order' => $args['order'] ?? 'DESC', - 'orderby' => $args['orderby'] ?? 'date', - 'posts_per_page' => $args['count'] ?? 8, + 'order' => $args['order'], + 'orderby' => $args['orderby'], + 'posts_per_page' => $args['count'], 'update_post_term_cache' => false, 'no_found_rows' => true ); -// Filter for author? -if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author']; +// Author? +if ( isset( $args['author'] ) && $args['author'] ) { + $query_args['author_name'] = $args['author']; +} // Taxonomies? if ( ! empty( $args['taxonomies'] ) ) {