Archived topic
Add meta fields for custom taxonomy
12 replies · Started by gpstart on December 2, 2022
I created a custom post type of Brand with a custom taxonomy called Retailer.
When a retailer archive is listed it looks like this:
Retailer: Nordstrom
Brand 1
Brand 2
etc.
I want to insert 2 custom fields (which I already created using MetaBox). One is website url and the other is instagram url. So that it looks like this:
Retailer: Nordstrom
Website url
Instagram url
Brand 1
Brand 2
etc.
I tried creating a block-hook, generate_after_entry_title, but, nothing shows up.
Can someone please tell me the steps to get this working?
Thanks.
Hi there,
for archives you would use the generate_after_archive_title
See here for reference:
https://docs.generatepress.com/article/hooks-visual-guide/#archives
Hi David,
I changed it to the above, cleared the cache, but, the website and instagram urls don't show up still.
Anything you can suggest to debug why it's not working?
What happens if you add some static text to test ? Does it show the static text ?
I put in the words "static text test" and it showed up.
So, I assume I'm not implementing the Headline block correctly.
I'm just checking something I'll update this in a moment.
Ok, I got it working now.
Just one thing though.
I'm using after_archive_title hook, but, it actually displays after the Description, not right after the title.
So, when the Retailer, Nordstrom displays, it shows up like this:
Retailer: Nordstrom
[Text from Description]
Custom field 1
Custom field 2
You can see my Element:
https://drops.cyberfilebox.com/JruywQLD
Output:
https://drops.cyberfilebox.com/NQu4engp
Any idea why it's not outputing after the title and before the Description?
It's working now.
I wonder if I need to clear my Cloudflare cache too? I didn't change anything and cleared my cache earlier, but, now it looks right.
I thought it worked earlier, but, I just realized I was looking at a retailer with no description so it looked like it was outputting my custom fields right after the archive title. But, after I added a description, the fields were pushed down after the description.
Hello there,
To clarify, are you referring to the custom field values you have not appearing when using a Headline Block?
Have you checked if the custom field name is set correctly in the Dynamic settings of the Headline Block?
If it isn't working can you try creating a new custom basic text field and try to output that using a Headline Block to test?
My custom fields are displaying with the correct link. But, they're not displaying in the correct location.
The fields are displaying after the Description as I showed in the 2nd link above.
https://drops.cyberfilebox.com/NQu4engp
Aren't those custom fields (website and instagram) supposed to display before the description and right after the archive title if I use the generate_after_archive_title hook?
I see. Thank you for clarifying. Yes, it should be after the title but can you try giving it a lower value priority so that it goes before the description?
Try giving the Element a priority of 1 for instance.
Let us know how it goes.
That did it!
Thank you once again!
You're welcome!