- This topic has 7 replies, 3 voices, and was last updated 3 years, 3 months ago by
Fernando.
-
AuthorPosts
-
December 7, 2022 at 4:19 am #2452825
Robert
Hi,
I am using:
Generatepress
Generateblocks
ACF
Custom Post Type UII have created a custom taxonomy called Sector using the Custom Post Type UI.
I then created a custom taxonomy field in ACF. I was able to select the sector taxonomy from the list.
I then go to my page editor and have the ability to create a ‘New Sector’ and have added a ‘Music’When I then use the dynamic data option within generateblocks I use data source as current post, Content source as meta data and the post meta field as sector. Nothing is displayed.
I have several other fields (not taxonomy) displaying correctly by exactly the same method on the same page.
There is data entered in the sector field.Can you help me understand what I am doing wrong and what to check?
I have a published page and near the top it says Sector and next to it should be the field data.
https://cryptosavvylife.com/project/audius-template-version/Lots of other data on the same page is coming from the Custom fields of ACF eg blockchain > Ethereum, Coin / Token > AUDIO
The main reason for creating the custom fields using ACF is for displaying various filter pages based on the field eg a page filtered by blockchain> Ethereum.
Thanks in advance!
RobDecember 7, 2022 at 11:28 am #2453539Ying
StaffCustomer SupportHi Rob,
Can you take screenshots of the settings of the sector in ACF and the settings in GB (how you pull the data)?
You can upload your screenshots here and share the link with us:
https://postimages.org/Let me know!
December 7, 2022 at 2:03 pm #2453716Robert
Hi,
I have been trying to play with this and have still had no luck but have changed the name of the field from sector to project_sector in case it was a conflict with the other title.I have attached lots of screen shots!
https://postimg.cc/gallery/dKxKqXq– The CPT UI Taxonomy – taken of the settings where I created the custom taxonomy
– ACF project sector – of the settings within the ACF plugin
– Page Layout 1 of the GB; this shows all the other fields I am using that all work
– Page layout showing Directory Fields; shows all the other fields including the project_sector that is populated with entertainment, music and gaming
– Website view; having updated the published page this is what I see, shows the other fields correctly with dynamic data but not the taxonomy / project_sector
Do let me know if logging in is helpful.
Thanks for your help,
December 7, 2022 at 6:25 pm #2453884Fernando Customer Support
Hi Robert,
Custom Taxonomies still isn’t supported as Dynamic data for GB.
Try adding
cu-tax-headlineto the classist of your Dynamic GB Headline Block.Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
Then, add this snippet:
add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){ if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'cu-tax-headline' ) !== false ) { $terms = get_field('custom-tax'); $output = '<ul>'; foreach( $terms as $term ){ $output = $output . '<li>' . '<a href="' . esc_url( get_term_link( $term ) ) . '">' . esc_html( $term->name ) . '</a></li>'; } $output = $output . '</ul'; return $output; } return $content; }, 10, 3);Replace
custom-taxwith your field nameproject_sectorAdding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
Let us know how it goes.
December 7, 2022 at 10:52 pm #2454051Robert
Thats great!!
It now comes as a bullet list (see photo link) and the fact that I can now link to that category is great. (Im hoping that I will now be able to search within those taxonomies?)If I add another custom taxonomy do I simply do the same again, with a different class name for the GB block and the appropriate field rather than project_sector, for the PHP?
Thanks,
RobDecember 7, 2022 at 11:47 pm #2454086Fernando Customer Support
You can apply custom CSS to alter the appearance of the categories if you want.
Can you clarify what you mean when you say “I’m hoping that I will now be able to search within those taxonomies?”
Yes, same code, just a different class and taxonomy field name.
We’re slowly adding support for more custom fields, and hopefully, in the near future, we can support this as well.
December 8, 2022 at 12:21 am #2454116Robert
Wow you guys are quick!
Absolutely the best support!!So I said search but think I mean filter?!
I would like to set up something that lets users filter for different sector and sub-sector.
I was planning to do it thru an element but not sure which or how yet, I need to follow the document videos!Thanks
December 8, 2022 at 12:36 am #2454137Fernando Customer Support
I’m not sure if I’m understanding correctly, but if you’re looking for a filter, you’ll need a third-party plugin for that. You can view this thread, some customers provided their insights, and useful plugins: https://community.generateblocks.com/t/taxonomy-filters-for-query-loop-block/1086
-
AuthorPosts
- You must be logged in to reply to this topic.