Update latest recommendations shortcode

This commit is contained in:
Tetrakern 2023-09-16 03:40:15 +02:00
parent 1e2062c17e
commit c6d2fe5081
2 changed files with 21 additions and 17 deletions

View File

@ -806,27 +806,29 @@ Filters the query arguments in the `fictioneer_latest_posts` shortcode. The opti
Filters the query arguments in the `fictioneer_latest_recommendations` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters. Filters the query arguments in the `fictioneer_latest_recommendations` shortcode. The optional taxonomy arrays can include categories, tags, fandoms, genres, and characters.
**$query_args:** **$query_args:**
* $fictioneer_query_name (string) `'latest_recommendations'` or `'latest_recommendations_compact'`
* $post_type (string) `'fcn_recommendation'` * $post_type (string) `'fcn_recommendation'`
* $post_status (string) `'publish'` * $post_status (string) `'publish'`
* $author_name (string|null) `$args['author']`
* $post__in (array) `$args['post_ids']` * $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']` * $category__not_in (array|null) `$args['excluded_cats']`
* $tag__not_in (array|null) `$args['excluded_tags']` * $tag__not_in (array|null) `$args['excluded_tags']`
* $orderby (string) `$args['orderby']` * $tax_query (array|null) `fictioneer_get_shortcode_tax_query( $args )`
* $order (string) `$args['order']`
* $posts_per_page (int) `$args['count']`
* $no_found_rows (boolean) `true` * $no_found_rows (boolean) `true`
**$args:** **$args:**
* $author (boolean|string) The author provided by the shortcode. Default `false`. * $count (int) Maximum number of posts. Default `-1`.
* $count (int) The number of posts provided by the shortcode. Default `1`. * $author (boolean|string) Limit posts to a specific author. Default `false`.
* $orderby (string) Optional. Default `'date'`. * $order (string) Order argument. Default `'DESC'`.
* $order (string) Optional. Default `'DESC'`. * $orderby (string) Orderby argument. Default `'date'`.
* $post_ids (\[string]) Array of post IDs. Default empty. * $post_ids (array) Limit posts to specific post IDs. Default empty.
* $ignore_protected (boolean) Optional. Whether to ignore protected posts. Default `false`. * $excluded_tags (array) Exclude specific tag names. Default empty.
* $excluded_cats (\[string]) Array of category IDs to exclude. Default empty. * $excluded_cats (array) Exclude specific category names. Default empty.
* $excluded_tags (\[string]) Array of tag IDs to exclude. Default empty. * $ignore_protected (boolean) Whether to ignore protected posts. Default `false`.
* $taxonomies (\[array]) Array of taxonomy arrays (names). Default empty. * $taxonomies (array) Array of arrays of required taxonomy names. Default empty.
* $relation (string) Relationship between taxonomies. Default `'AND'`. * $relation (string) Relationship between taxonomies. Default `'AND'`.
* $classes (string) String of additional CSS classes. Default empty. * $classes (string) String of additional CSS classes. Default empty.

View File

@ -36,14 +36,16 @@ $query_args = array (
'post_type' => 'fcn_recommendation', 'post_type' => 'fcn_recommendation',
'post_status' => 'publish', 'post_status' => 'publish',
'post__in' => $args['post_ids'], // May be empty! 'post__in' => $args['post_ids'], // May be empty!
'orderby' => $args['orderby'] ?? 'date', 'order' => $args['order'],
'order' => $args['order'] ?? 'DESC', 'orderby' => $args['orderby'],
'posts_per_page' => $args['count'], 'posts_per_page' => $args['count'],
'no_found_rows' => true 'no_found_rows' => true
); );
// Parameter for author? // Author?
if ( isset( $args['author'] ) && $args['author'] ) $query_args['author_name'] = $args['author']; if ( isset( $args['author'] ) && $args['author'] ) {
$query_args['author_name'] = $args['author'];
}
// Taxonomies? // Taxonomies?
if ( ! empty( $args['taxonomies'] ) ) { if ( ! empty( $args['taxonomies'] ) ) {