Improves dynamic render of tainacan metadata block. #566.
This commit is contained in:
parent
6065da3970
commit
bfd35abb70
|
@ -1566,8 +1566,15 @@ class Theme_Helper {
|
|||
if ( !$collection_id )
|
||||
return '';
|
||||
|
||||
if ( isset($args['metadata']) )
|
||||
$args['p'] = $args['metadata'];
|
||||
//$args['posts_per_page'] = 1;
|
||||
|
||||
if ( isset($args['metadata__in']) )
|
||||
$args['post__in'] = $args['metadata__in'];
|
||||
|
||||
if ( isset($args['metadata__not_in']) )
|
||||
$args['post__not_in'] = $args['metadata__not_in'];
|
||||
|
||||
$collection = \Tainacan\Repositories\Collections::get_instance()->fetch($collection_id);
|
||||
$metadata = \Tainacan\Repositories\Metadata::get_instance()->fetch_by_collection($collection, $args);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ export default function ({ attributes, setAttributes, className, isSelected }) {
|
|||
'tainacan/item-metadata',
|
||||
{
|
||||
sectionId: String(sectionId),
|
||||
itemId: Number(itemId),
|
||||
itemId: isDynamic ? Number(itemId) : 0,
|
||||
collectionId: Number(collectionId),
|
||||
metadata: sectionMetadata,
|
||||
dataSource: 'parent',
|
||||
|
|
|
@ -18,7 +18,7 @@ function tainacan_blocks_render_item_metadata( $block_attributes, $content, $blo
|
|||
|
||||
// Builds args from backend query
|
||||
$args = [
|
||||
'metadata_in' => array_map(function($metadatum) { return $metadatum['id']; }, $metadata)
|
||||
'metadata__in' => array_map(function($metadatum) { return $metadatum['id']; }, $metadata)
|
||||
];
|
||||
|
||||
if ( $template_mode && $collection_id ) {
|
||||
|
|
Loading…
Reference in New Issue