Adds order option to related items query in the theme helper function.

This commit is contained in:
mateuswetah 2022-10-14 12:05:37 -03:00
parent 307d9d48f5
commit a00e8fb11e
1 changed files with 6 additions and 1 deletions

View File

@ -1054,6 +1054,7 @@ class Theme_Helper {
* Optional. Array of arguments.
* @type string $item_id The Item ID
* @type string $items_list_layout The type of list to be rendered. Accepts 'grid', 'list', 'mosaic' and 'carousel'.
* @type string $order Sorting direction to the related items query. Either 'desc' or 'asc'.
* @type string $class_name Extra class to add to the wrapper, besides the default wp-block-tainacan-carousel-related-items
* @type string $collection_heading_class_name Extra class to add to the collection name wrapper. Defaults to ''
* @type string $collection_heading_tag Tag to be used as wrapper of the collection name. Defaults to h2
@ -1081,7 +1082,11 @@ class Theme_Helper {
return;
// Then fetches related ones
$related_items = $item->get_related_items();
$related_items_query_args = [];
if ( isset($args['order']) )
$related_items_query_args['order'] = $args['order'];
$related_items = $item->get_related_items($related_items_query_args);
if (!count($related_items))
return;