Support Forum
Hello,
I'm trying to use Views to display custom taxonomy terms on the homepage.
But when I click on "Insert field" only post fields are showing, custom post types or taxonomies are not shown.
Do you know why the fields of custom post types or taxonomies are not showing?
Thanks in advance,
Sandra
Hi Sandra,
By default, all the post fields will show on the tab Post, see my screenshots
https://cl.ly/e923f9b77fd5
https://cl.ly/53485a259d05
Could you please clear the cache and check the Insert Field again? Or take some screenshots in your end.
I tried adding screenshots before but without succes.
I've now copied the links to the screenshots one by one in the former replies.
Hi,
To insert the taxonomies, please use the post field Post term list
see my screenshot https://cl.ly/d65c03f5cde2
Ah great, thanks Long!
But when I paste the shortcode on the page, nothing is shown on the front page and Elementor is not loading in the backend.
https://share.getcloudapp.com/geuWZmQE
When I click "Edit with Elementor" (on the page with the shortcode) Elementor is not loading. I see the next error:
"
Uncaught Twig_Error_Loader: Template "template" is not defined. in /home/..../wp-content/plugins/meta-box-builder/vendor/twig/twig/lib/Twig/Loader/Array.php:80
Stack trace:
#0 /home/..../wp-content/plugins/meta-box-builder/vendor/twig/twig/lib/Twig/Environment.php(329): Twig_Loader_Array->getCacheKey('template')
#1 /home/.../wp-content/plugins/meta-box-builder/vendor/twig/twig/lib/Twig/Environment.php(419): Twig_Environment->getTemplateClass('template')
#2 /home/.../wp-content/plugins/meta-box-builder/vendor/twig/twig/lib/Twig/Environment.php(362): Twig_Environment->loadTemplate('template')
#3 /home/.../wp-content/plugins/mb-views/src/Renderer.php(42): Twig_Environment->render('template', Array)
#4 /home/..../wp-content/plugins/mb-views/src/Shortcode.ph
"
Am I doing something wrong?
Oh sorry, I used a view which was deleted.
I'm using the right shortcode now and Elementor is loading but still nothing is shown on the front end.
Is there something wrong with the view?
Hi,
I've made a short screen record about using Views shortcode and add to Elementor widget shortcode https://www.loom.com/share/9049c378c176415793dbc82168572b34
Remember don't add the Location in the View item because the location page will use a specific template (generated by this extension) and you cannot edit this page with Elementor any more.
Hi,
Thanks a lot for the screen record! I understand now why it wasn't working.
Sorry, one more question:
Is it also possible with a shortcode to list all the terms of a taxonomy on for instance the home page? Like all the symptoms in the taxonomy symptoms? (independent of the post)
Hi,
In View, you can use this sample code to list the terms of the taxonomy
<h2>Categories: </h2>
{% set terms = mb.get_terms( 'category' ) %}
{% for term in terms %}
{{term.name}} <br>
{% endfor %}
use the function get_terms()
supported by WordPress via Proxy mb.
For more information, please follow the documentation
https://developer.wordpress.org/reference/functions/get_terms/
Ok, thanks Long for all your good and quick answers!
Highly appreciated.
Thanks!
With some trial and error I managed to add the links to the term archive.
I've used the following code:
{% set terms = mb.get_terms( 'symptoom' ) %}
{% for term in terms %}
{% set termlink = mb.get_term_link(term)%}
<a href="{{termlink}}">{{term.name}}</a> ,
{% endfor %}
It works, but I'm not sure if this is the best way to write the code.
So, please show me if I should write it differently.
Hi,
Yeah, the code shows the terms of symptoom
and link to the archive page as well. Keep up the good work.
Thanks, with your help I'm learning to use Metabox.io and I'm finding out it can really do a lot! Next thing I'm going to use is MB Relationships and MB Admin Columns.