Add exclude parameters to latest_chapters
This commit is contained in:
parent
32b5a904ea
commit
ef97a81859
@ -385,8 +385,8 @@ Renders paginated blog posts akin to the default blog page, but with options. Ma
|
||||
|
||||
* **per_page:** Number of posts per page. Defaults to theme settings.
|
||||
* **author:** Only show chapters of a specific author. Make sure to write the name right.
|
||||
* **exclude_cat_ids:** Comma-separated list of category IDs, if you want to exclude some.
|
||||
* **exclude_tag_ids:** Comma-separated list of tag IDs, if you want to exclude some.
|
||||
* **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.
|
||||
* **rel:** Relationship between different taxonomies, either `AND` or `OR`. Default `AND`.
|
||||
@ -487,7 +487,7 @@ Renders two buttons to deal with cookies, "Reset Consent" and "Clear Cookies". B
|
||||
|
||||
### Latest Chapters
|
||||
|
||||
Renders a two-column grid of small cards, showing the latest four chapters ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **spoiler**, **source**, **post_ids**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**.
|
||||
Renders a two-column grid of small cards, showing the latest four chapters ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **spoiler**, **source**, **post_ids**, **exclude_cat_ids**, **exclude_tag_ids**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**.
|
||||
|
||||
* **count:** Limit chapters to any positive number, although you should keep it reasonable. Default `4`.
|
||||
* **type:** Either `default`, `simple`, or `compact`. The other variants are smaller with less data.
|
||||
@ -497,6 +497,8 @@ Renders a two-column grid of small cards, showing the latest four chapters order
|
||||
* **spoiler:** The excerpt is obfuscated, set `true` if you want to reveal it. Default `false`.
|
||||
* **source:** Set `false` to hide the author and story nodes. Default `true`.
|
||||
* **post_ids:** 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.
|
||||
|
@ -540,6 +540,8 @@ Filters the query arguments in the `fictioneer_latest_chapters` shortcode. The o
|
||||
* $post__in (array) – `$args['post_ids']`
|
||||
* $meta_key (string) – `'fictioneer_chapter_hidden'`
|
||||
* $meta_value (int) – `0`
|
||||
* $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']`
|
||||
@ -555,6 +557,8 @@ Filters the query arguments in the `fictioneer_latest_chapters` shortcode. The o
|
||||
* $spoiler (boolean) – Optional. Show preview un-obfuscated. Default `false`.
|
||||
* $source (boolean) – Optional. Show chapter source story. Default `true`.
|
||||
* $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.
|
||||
|
@ -298,20 +298,22 @@ add_shortcode( 'fictioneer_showcase', 'fictioneer_shortcode_showcase' );
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
* @param string|null $attr['count'] Optional. Maximum number of items. Default 4.
|
||||
* @param string|null $attr['author'] Optional. Limit items to a specific author.
|
||||
* @param string|null $attr['orderby'] Optional. Order argument. Default 'date'.
|
||||
* @param string|null $attr['type'] Optional. Choose between 'default', 'simple', and 'compact'.
|
||||
* @param string|null $attr['spoiler'] Optional. Whether to show spoiler content.
|
||||
* @param string|null $attr['source'] Optional. Whether to show author and story.
|
||||
* @param string|null $attr['post_ids'] Optional. Limit items to specific post IDs.
|
||||
* @param string|null $attr['categories'] Optional. Limit items to specific category names.
|
||||
* @param string|null $attr['tags'] Optional. Limit items to specific tag names.
|
||||
* @param string|null $attr['fandoms'] Optional. Limit items to specific fandom names.
|
||||
* @param string|null $attr['genres'] Optional. Limit items to specific genre names.
|
||||
* @param string|null $attr['characters'] Optional. Limit items to specific character names.
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
* @param string|null $attr['count'] Optional. Maximum number of items. Default 4.
|
||||
* @param string|null $attr['author'] Optional. Limit items to a specific author.
|
||||
* @param string|null $attr['orderby'] Optional. Order argument. Default 'date'.
|
||||
* @param string|null $attr['type'] Optional. Choose between 'default', 'simple', and 'compact'.
|
||||
* @param string|null $attr['spoiler'] Optional. Whether to show spoiler content.
|
||||
* @param string|null $attr['source'] Optional. Whether to show author and story.
|
||||
* @param string|null $attr['post_ids'] Optional. Limit items to specific post IDs.
|
||||
* @param string|null $attr['exclude_tag_ids'] Optional. Exclude posts with these tags.
|
||||
* @param string|null $attr['exclude_cat_ids'] Optional. Exclude posts with these categories.
|
||||
* @param string|null $attr['categories'] Optional. Limit items to specific category names.
|
||||
* @param string|null $attr['tags'] Optional. Limit items to specific tag names.
|
||||
* @param string|null $attr['fandoms'] Optional. Limit items to specific fandom names.
|
||||
* @param string|null $attr['genres'] Optional. Limit items to specific genre names.
|
||||
* @param string|null $attr['characters'] Optional. Limit items to specific character names.
|
||||
* @param string|null $attr['rel'] Optional. Relationship between taxonomies. Default 'AND'.
|
||||
* @param string|null $attr['class'] Optional. Additional CSS classes, separated by whitespace.
|
||||
*
|
||||
* @return string The rendered shortcode HTML.
|
||||
*/
|
||||
@ -353,6 +355,8 @@ function fictioneer_shortcode_latest_chapters( $attr ) {
|
||||
'spoiler' => $spoiler == 'true',
|
||||
'source' => $source == 'true',
|
||||
'post_ids' => $post_ids,
|
||||
'excluded_tags' => fictioneer_explode_list( $attr['exclude_tag_ids'] ?? '' ),
|
||||
'excluded_cats' => fictioneer_explode_list( $attr['exclude_cat_ids'] ?? '' ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => $rel,
|
||||
'classes' => $classes
|
||||
|
@ -8,16 +8,18 @@
|
||||
* @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['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @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['class'] Additional classes.
|
||||
* @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['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @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['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -45,6 +47,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_chapters_query_args', $query_args, $args );
|
||||
|
||||
|
@ -8,17 +8,19 @@
|
||||
* @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['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @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['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
* @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['spoiler'] Whether to obscure or show chapter excerpt.
|
||||
* @internal $args['source'] Whether to show author and story.
|
||||
* @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['simple'] Whether to show the simple variant.
|
||||
* @internal $args['class'] Additional classes.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -46,6 +48,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_chapters_query_args', $query_args, $args );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user