Skip Navigation

[Resolved] [wpv-search-term param='wpv-xxx] display the name and not the slug

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Ido Angel 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1168658

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!

#1169019

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.

#1169419

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

#1169846

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.

#1169884

got it 🙂
thanks C!