Add exclude parameters to latest_recommendations
This commit is contained in:
parent
c7fe07e945
commit
0db0ffd852
@ -549,7 +549,7 @@ Renders the last blog post or a list of blog posts, ignoring sticky posts, order
|
||||
|
||||
### Latest Recommendations
|
||||
|
||||
Renders a two-column grid of small cards, showing the latest four recommendations ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **post_ids**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**.
|
||||
Renders a two-column grid of small cards, showing the latest four recommendations ordered by publishing date, descending. Optional parameters are **count**, **type**, **author**, **order**, **orderby**, **post_ids**, **exclude_cat_ids**, **exclude_tag_ids**, **categories**, **tags**, **fandoms**, **genres**, **characters**, **rel**, and **class**.
|
||||
|
||||
* **count:** Limit recommendations 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.
|
||||
@ -557,6 +557,8 @@ Renders a two-column grid of small cards, showing the latest four recommendation
|
||||
* **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).
|
||||
* **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.
|
||||
|
@ -598,6 +598,8 @@ Filters the query arguments in the `fictioneer_latest_recommendations` shortcode
|
||||
* $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']`
|
||||
* $orderby (string) – `$args['orderby']`
|
||||
* $order (string) – `$args['order']`
|
||||
* $posts_per_page (int) – `$args['count']`
|
||||
@ -609,6 +611,8 @@ Filters the query arguments in the `fictioneer_latest_recommendations` shortcode
|
||||
* $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.
|
||||
|
@ -556,17 +556,19 @@ add_shortcode( 'fictioneer_update_cards', 'fictioneer_shortcode_latest_story_upd
|
||||
*
|
||||
* @since 4.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['type'] Optional. Choose between 'default' and 'compact'.
|
||||
* @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['type'] Optional. Choose between 'default' and 'compact'.
|
||||
* @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.
|
||||
*/
|
||||
@ -603,6 +605,8 @@ function fictioneer_shortcode_latest_recommendations( $attr ) {
|
||||
'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'] ?? '' ),
|
||||
'taxonomies' => fictioneer_get_shortcode_taxonomies( $attr ),
|
||||
'relation' => $rel,
|
||||
'classes' => $classes
|
||||
|
@ -8,13 +8,15 @@
|
||||
* @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['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.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -42,6 +44,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_recommendations_query_args', $query_args, $args );
|
||||
|
||||
|
@ -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['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['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.
|
||||
*/
|
||||
?>
|
||||
|
||||
@ -43,6 +45,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_recommendations_query_args', $query_args, $args );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user