hey,
after a user searches with filtering a taxonomy, i am presenting a string:
you search for: [wpv-search-term param='wpv-known-as']
the string is placed outside the actual loop, because i want to show it once and not inside every item in the results.
the only problem is it gives me the search term slug and not name, so if i have a slug with more than 1 word i get a "-" between them.
if i try to present the actual taxonomy term, of course i get it empty, because it's outside of the loop.
i tried creating a child view just for this string, filtered it according to url-parameter and placed it inside the main view - but got the same results.
any ideas?
thanks!
Unfortunately you can't filter a View of a taxonomy by term slug, only by term ID. If you want to display the term names in a View, you would have to filter that View by term ID. So that means you must create a custom shortcode that converts the wpv-known-as URL parameter(s) into a comma-separated list of IDs. Something that inspects the params in the $_GET superglobal, then loops over them and calls get_term_by('slug',...) and outputs a comma-separated list of term IDs like 1,2,3,4. Once you have that working, you can use the shortcode in a View filter.
https://codex.wordpress.org/Function_Reference/get_term_by
Then create a View of this taxonomy filtered by term ID, set by a shortcode attribute. Place your term View where you have wpv-search-param now, and add your custom shortcode as a View shortcode attribute. Register your custom shortcode in Toolset > Settings > Front-end content > Third party shortcode arguments.
hey christian,
thanks for replying 🙂
hmmm... seems quite complicated. all i wanted was that [wpv-search-term param='wpv-known-as'] will show the term name and not term slug.
Unless there's a simpler way to present this I think in this case it might be easier to create some jQuery code to replace the slug with the title.
Cheers
Ido
all i wanted was that [wpv-search-term param='wpv-known-as'] will show the term name and not term slug.
Yes, it seems like a simple task but it's not. It is quite complicated, because the wpv-search-term shortcode isn't meant to translate taxonomy term slugs into taxonomy term titles, and none of the Types or Views shortcodes are designed to produce term titles from term slugs.