diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index e0bd94e0..2aeb4a16 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -579,7 +579,7 @@ Renders a two-column grid of small cards, showing the latest four recommendation ### Latest Stories -Renders a two-column grid of small cards, showing the latest four stories ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **stories**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**. +Renders a two-column grid of small cards, showing the latest four stories ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **stories**, **exclude_cat_ids**, **exclude_tag_ids**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**. * **count:** Limit stories to any positive number, although you should keep it reasonable. Default `4`. * **type:** Either `default` or `compact`. The compact variant is smaller with less data. @@ -587,6 +587,8 @@ Renders a two-column grid of small cards, showing the latest four stories ordere * **order:** Either `desc` (descending) or `asc` (ascending). Default `desc`. * **orderby:** The default is `date`, but you can also use `modified` and [more](https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters). * **stories:** Comma-separated list of post IDs, if you want to pick from a curated pool. +* **exclude_cat_ids:** Comma-separated list of category IDs to exclude. +* **exclude_tag_ids:** Comma-separated list of tag IDs to exclude. * **categories:** Comma-separated list of category names (case-insensitive), if you want to pick from a curated pool. * **tags:** Comma-separated list of tag names (case-insensitive), if you want to pick from a curated pool. * **fandoms:** Comma-separated list of fandom names (case-insensitive), if you want to pick from a curated pool. diff --git a/FILTERS.md b/FILTERS.md index 93100ad0..9a5f6cbd 100644 --- a/FILTERS.md +++ b/FILTERS.md @@ -619,6 +619,8 @@ Filters the query arguments in the `fictioneer_latest_stories` shortcode. The op * $post_status (string) – `'publish'` * $author_name (string|null) – `$args['author']` * $post__in (array) – `$args['post_ids']` +* $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']` @@ -631,6 +633,8 @@ Filters the query arguments in the `fictioneer_latest_stories` shortcode. The op * $orderby (string) – Optional. Default `'date'`. * $order (string) – Optional. Default `'desc'`. * $post_ids (\[string]) – Array of post IDs. Default empty. +* $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. * $relation (string) – Relationship between taxonomies. Default `'AND'`. * $classes (\[string]) – Array of additional CSS classes. Default empty. diff --git a/partials/_latest-stories-compact.php b/partials/_latest-stories-compact.php index a89587cc..b760acd3 100644 --- a/partials/_latest-stories-compact.php +++ b/partials/_latest-stories-compact.php @@ -8,14 +8,16 @@ * @subpackage Fictioneer * @since 4.0 * - * @internal $args['count'] Number of posts provided by the shortcode. - * @internal $args['author'] Author provided by the shortcode. - * @internal $args['order'] Order of posts. Default 'desc'. - * @internal $args['orderby'] Sorting of posts. Default 'date'. - * @internal $args['post_ids'] Array of post IDs. Default empty. - * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. - * @internal $args['relation'] Relationship between taxonomies. - * @internal $args['classes'] Array of additional CSS classes. Default empty. + * @internal $args['count'] Number of posts provided by the shortcode. + * @internal $args['author'] Author provided by the shortcode. + * @internal $args['order'] Order of posts. Default 'desc'. + * @internal $args['orderby'] Sorting of posts. Default 'date'. + * @internal $args['post_ids'] Array of post IDs. Default empty. + * @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty. + * @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty. + * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. + * @internal $args['relation'] Relationship between taxonomies. + * @internal $args['classes'] Array of additional CSS classes. Default empty. */ ?> @@ -41,6 +43,16 @@ if ( ! empty( $args['taxonomies'] ) ) { $query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args ); } +// Excluded tags? +if ( ! empty( $args['excluded_tags'] ) ) { + $query_args['tag__not_in'] = $args['excluded_tags']; +} + +// Excluded categories? +if ( ! empty( $args['excluded_cats'] ) ) { + $query_args['category__not_in'] = $args['excluded_cats']; +} + // Apply filters $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_args', $query_args, $args ); diff --git a/partials/_latest-stories.php b/partials/_latest-stories.php index e81f17c6..2d625fa9 100644 --- a/partials/_latest-stories.php +++ b/partials/_latest-stories.php @@ -8,14 +8,16 @@ * @subpackage Fictioneer * @since 4.0 * - * @internal $args['count'] Number of posts provided by the shortcode. - * @internal $args['author'] Author provided by the shortcode. - * @internal $args['order'] Order of posts. Default 'desc'. - * @internal $args['orderby'] Sorting of posts. Default 'date'. - * @internal $args['post_ids'] Array of post IDs. Default empty. - * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. - * @internal $args['relation'] Relationship between taxonomies. - * @internal $args['classes'] Array of additional CSS classes. Default empty. + * @internal $args['count'] Number of posts provided by the shortcode. + * @internal $args['author'] Author provided by the shortcode. + * @internal $args['order'] Order of posts. Default 'desc'. + * @internal $args['orderby'] Sorting of posts. Default 'date'. + * @internal $args['post_ids'] Array of post IDs. Default empty. + * @internal $args['excluded_cats'] Array of category IDs to exclude. Default empty. + * @internal $args['excluded_tags'] Array of tag IDs to exclude. Default empty. + * @internal $args['taxonomies'] Array of taxonomy arrays. Default empty. + * @internal $args['relation'] Relationship between taxonomies. + * @internal $args['classes'] Array of additional CSS classes. Default empty. */ ?> @@ -41,6 +43,16 @@ if ( ! empty( $args['taxonomies'] ) ) { $query_args['tax_query'] = fictioneer_get_shortcode_tax_query( $args ); } +// Excluded tags? +if ( ! empty( $args['excluded_tags'] ) ) { + $query_args['tag__not_in'] = $args['excluded_tags']; +} + +// Excluded categories? +if ( ! empty( $args['excluded_cats'] ) ) { + $query_args['category__not_in'] = $args['excluded_cats']; +} + // Apply filters $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_args', $query_args, $args );