# Hooks Help

**URL:** https://tainacan.discourse.group/t/hooks-help/1410
**Category:** Dúvidas
**Created:** [Maio 15, 2023, 8:50pm UTC](https://tainacan.discourse.group/t/hooks-help/1410 "2023-05-15T20:50:15Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![eeszarek](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/eeszarek/32/1666_2.png) [@eeszarek](https://tainacan.discourse.group/u/eeszarek)
#### Post date: [Maio 15, 2023, 8:50pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/1 "2023-05-15T20:50:15Z")

</div>

Where do I add the hook for this? It is three functions deep.  
tainacan\_the\_metadata \> tainacan\_get\_the\_metadata \> \>get\_metadata\_as\_html.  
I would like to pull the session data and the link associated, like this:  
 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/c/c264abcd2a1351742e7ef9b50125cf1fb34412ca.png)  
and put it here:

 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/2/21ff185013a05ca00311afb67169f5b1e45d0df7.png)

_The function in question:_  
 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/e/e5abe4222abad456840538fabbffd09106b4a386.png)

I would like to pass

```auto
array(
							'metadata'	=> 'session'
};

```

to it. I guess I am having trouble finding hooks.

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Maio 16, 2023, 12:44am UTC](https://tainacan.discourse.group/t/hooks-help/1410/2 "2023-05-16T00:44:02Z")

</div>

Hi @eeszarek, maybe this one?

> <https://github.com/tainacan/tainacan/blob/develop/src/classes/entities/class-tainacan-item.php#L787>

Could you explain in more details what you are trying to achieve? Maybe there is a way vie theme but there are several filters in the \_as\_html functions. In this case, the `$item_metadatum` object should contain information from the current item, the metadata and its value.

---

<div class="post-metadata">

### Author: ![eeszarek](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/eeszarek/32/1666_2.png) [@eeszarek](https://tainacan.discourse.group/u/eeszarek)
#### Post date: [Junho 6, 2023, 8:19pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/3 "2023-06-06T20:19:35Z")

</div>

Hello, I am still struggling with this.  
My single-item pages look like this.

 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/3/3357dc50bf859fb1c9d3f1cfe2a8db8d0c4c5364.png)  
I can click through the value\_as\_html link to go to this:  
 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/7/740eb98c9374cb81b7948d1f7b3c62b995931eb7.png)  
but I would like to add a navigation part to my first page, like this from Association for cultural equity.  
[https://archive.culturalequity.org/dli/arnoldgrauerlomax-1961](https://archive.culturalequity.org/dli/arnoldgrauerlomax-1961)  
 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/3/3512e01670cf6c624040553d0094c780781926f0.png)  
I have tried various API calls but I am really struggling with it.

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Junho 7, 2023, 5:13pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/4 "2023-06-07T17:13:26Z")

</div>

Hi @eeszarek!

If I understood right, you would like to show items that belong to this Taxonomy Term (Murrels Inlet June 1939). In the I Lost My Mother’s Barn Key item page, including the filters, in a sort of “Related items section”. Is that it?

If it is, two things come to my mind. One is that you could probably achieve this easily with a Relationship metadata instead of a Taxonomy. Maybe using the “[Items related to this](https://tainacan.org/en/blog/2021/07/15/tainacan-beta-0-18-3-improvements-on-the-item-edition-and-items-related-to-this/#8220Items_related_to_this8221)” feature combined with the [Detailed Metadata Displayed](https://tainacan.org/en/blog/2021/09/28/tainacan-beta-0-18-6-detailed-item-relationship-new-tags-options-for-blocks-and-embeded-url-document/#Metadata_displayed_in_the_relationship) in the relationship? In any case that would still not display filters, as in our default “related items” views we usually have a Carousel or more simple list, that would end with a button targeting the full items list with filters. Here you can see them in the theme-side:

> **[Tainacan Interface 2.4 and Tainacan Support for Blocksy 0.1.10](https://tainacan.org/en/blog/2021/07/15/tainacan-interface-2-4-and-tainacan-support-for-blocksy-0-1-10/)**
>
> Version 0.18.3 of the Tainacan plugin is ready to go and right behind it are coming updates so that our Tainacan Interface theme and Blocksy theme users can\[...\]

That said, another thing that may be what you are looking for is the ability to render a complete faceted search (the items list with filters) in this page. There is a function named `tainacan_the_faceted_search()` that can also be displayed using a shortcode (`tainacan-search`). This function accepts several parameters. You can read all of them here:

> <https://github.com/tainacan/tainacan/blob/develop/src/classes/theme-helper/class-tainacan-theme-helper.php#L550>

If you pass a `term_id`, it will render the list of items that were tagged to that taxonomy term. I’ve never did anything such as displaying a new items list inside the item page… but it might work.

Let me know how this goes!

---

<div class="post-metadata">

### Author: ![eeszarek](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/eeszarek/32/1666_2.png) [@eeszarek](https://tainacan.discourse.group/u/eeszarek)
#### Post date: [Junho 7, 2023, 5:39pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/5 "2023-06-07T17:39:59Z")

</div>

That is awesome, thank you so much. I should have just asked for clarification earlier! I will give this a try, it looks like it is exactly what I need.

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Junho 7, 2023, 5:42pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/6 "2023-06-07T17:42:31Z")

</div>

Glad to help!

Also, the “Items related to this” section is “relatioship-metadata” based, but if you would like to display related items based on a taxonomy, the Blocksy theme has this feature by default, you may give it a try using our integration plugin. Let me know if you go that way so I can give further clarifications.

---

<div class="post-metadata">

### Author: ![eeszarek](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/eeszarek/32/1666_2.png) [@eeszarek](https://tainacan.discourse.group/u/eeszarek)
#### Post date: [Junho 7, 2023, 5:50pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/7 "2023-06-07T17:50:37Z")

</div>

We use the Tainacan Interface theme on our website. Does that change how it works?

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Junho 7, 2023, 5:53pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/8 "2023-06-07T17:53:46Z")

</div>

It would be another theme with another appearance. You may want to try, but it is up to you to see which you prefer.

Here is the theme:

> **[Blocksy](https://wordpress.org/themes/blocksy/)**
>
> Blocksy is a blazing fast and lightweight WordPress theme built with the latest web technologies. It was built with the Gutenberg editor in mind and has a lot of options that makes it extendable and customizable. You can easily create any type of...

Here is our integration plugin:

> **[Tainacan Support for Blocksy](https://wordpress.org/plugins/tainacan-blocksy/)**
>
> A plugin for integrating Tainacan plugin pages with the amazing Blocksy theme.

And for enabling related items, you would look for something like “Customizer” → “Item from collection X” → “Related posts”. I can give better details later if tou go that way.

---

<div class="post-metadata">

### Author: ![eeszarek](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/eeszarek/32/1666_2.png) [@eeszarek](https://tainacan.discourse.group/u/eeszarek)
#### Post date: [Junho 9, 2023, 1:55pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/9 "2023-06-09T13:55:30Z")

</div>

Thank you so much for this! I really made some progress.

 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/b/b9027f18b658d37117b2225d2a4ce827f31666b0.png)  
 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/a/afd7001016cc707629ce0950ad736a746fb5cbed.png)

Now I am wondering if there is a way to make a query from these items. For example, would it be possible to do the faceted search then add a metaquery?  
Something like:

```auto

$items = tainacan_get_items(array(
    'meta_query' => array(
        array(
            'key' => 'original_filename',
            'value' => 'ace_mi_19390608_2719B*',
            'compare' => 'LIKE',
        ),
    ),
));

```

So that the list would only be

 ![image](https://global.discourse-cdn.com/free1/uploads/tainacan/original/2X/a/aea19f38013e7026f7db79e07f05feae50172812.png)

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Junho 9, 2023, 3:21pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/10 "2023-06-09T15:21:42Z")

</div>

Uhmmm, sadly no, the faceted search function does not accept queries like that. Partially because itself builds internally the queries to be performed according to the existing filters, view modes, etc.

If you want to have more control over the queries, you could build a WP\_Query manually with the meta and tax queries and then build the loop by your own…but I guess that may be too much work depending on what you are trying to achieve. If a simple “carousel” or “grid” view suffice you, there is the get\_tainacan\_items\_carousel() and get\_tainacan\_dynamic\_items\_list() functions, which accept a list items as input. Take a look here:

> <https://github.com/tainacan/tainacan/blob/a172c6c29376c1c90fba407a57cddace1819aff6/src/classes/theme-helper/class-tainacan-theme-helper.php#LL1136C28-L1136C28>

This is the function definition inside the theme helper. To call them, you would use a function from the template tags, like this:

> <https://github.com/tainacan/tainacan/blob/a172c6c29376c1c90fba407a57cddace1819aff6/src/classes/theme-helper/template-tags.php#L1052>

---

<div class="post-metadata">

### Author: ![mateus.m.luna](https://yyz2.discourse-cdn.com/free1/user_avatar/tainacan.discourse.group/mateus.m.luna/32/3_2.png) [@mateus.m.luna](https://tainacan.discourse.group/u/mateus.m.luna)
#### Post date: [Junho 9, 2023, 3:24pm UTC](https://tainacan.discourse.group/t/hooks-help/1410/11 "2023-06-09T15:24:28Z")

</div>

One note, this functions are the same evoked to render their Gutenberg blocks counterparts. So 99% of what you can do with the blocks you can do with them. In this case, you would build the WP\_Query to fetch exactly the items that you want and then would pass them as argument in the `selected_items` prop.
