Skip Navigation

[Resolved] Modifying Loop Output Editor in View that will pass a taxonomy value to ‘a href’

This thread is resolved. Here is a description of the problem and solution.

Problem: If a URL is submit by a user (via CRED form) as a custom taxonomy (slug 'link-to-buy') within a custom post type (slug 'jean-purchase-info') can I show that URL as a clickable link (where the href target is the 'link-to-buy') with generic text displayed like "buy here" rather than showing the URL?

Solution:
Yes and no. This is a tricky one because you have implemented a URL as a taxonomy term instead of a URL custom field. To display taxonomy terms associated with a post, you will use the [wpv-post-taxonomy] shortcode.

The problem is that this shortcode lists all terms from this taxonomy assigned to the post. So if more than one term is applied, this approach won't work because it will not allow you to create multiple links from multiple terms. Also if any terms in this taxonomy you have applied to these posts are not URLs, this approach will not work either because they will be displayed as broken links here.

So if you only have one term from this taxonomy applied to any post, and all the applied terms in this taxonomy are URLs, then you can do something like this:

<a href="[wpv-post-taxonomy type='custom-tax-slug' format='name']">Buy here</a>

Otherwise, you'll need to consider a different method of saving these URLs, perhaps in a repeating URL custom field.

Relevant Documentation: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy

This support ticket is created 7 years 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 Todd 7 years ago.

Assisted by: Christian Cox.

Author
Posts
#588851

If a URL is submit by a user (via CRED form) as a custom taxonomy (slug 'link-to-buy') within a custom post type (slug 'jean-purchase-info') can I show that URL as a clickable link (where the href target is the 'link-to-buy') with generic text displayed like "buy here" rather than showing the URL?

For example if the link submit was "www.jeanshop.com/favoritejeans" I'd like to see HTML like "hidden link">Buy here"

On my site users can submit Review and post Pictures about certain types of Jeans with some custom taxonomies. Reviews and Pictures are custom post types that are children of the parent Jeans post type. I have successfully created CRED forms and Views for user submission of Reviews and Pictures, and modified the Jean Layout to display the appropriate child Reviews and Pictures of the parent Jean. Your products are awesome!

Can I use the same process but tweak the View to achieve the outbound link that I want? It sounds like the only difficult part is tweaking the Loop Output Editor section code but if I am off base here I can take a different approach.

#588952

If a URL is submit by a user (via CRED form) as a custom taxonomy (slug 'link-to-buy') within a custom post type (slug 'jean-purchase-info') can I show that URL as a clickable link (where the href target is the 'link-to-buy') with generic text displayed like "buy here" rather than showing the URL?
Yes and no. This is a tricky one because you have implemented a URL as a taxonomy term instead of a URL custom field. To display taxonomy terms associated with a post, you will use the [wpv-post-taxonomy] shortcode.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy

The problem is that this shortcode lists all terms from this taxonomy assigned to the post. So if more than one term is applied, this approach won't work because it will not allow you to create multiple links from multiple terms. Also if any terms in this taxonomy you have applied to these posts are not URLs, this approach will not work either because they will be displayed as broken links here.

So if you only have one term from this taxonomy applied to any post, and all the applied terms in this taxonomy are URLs, then you can do something like this:

<a href="[wpv-post-taxonomy type='custom-tax-slug' format='name']">Buy here</a>

Otherwise, you'll need to consider a different method of saving these URLs, perhaps in a repeating URL custom field.

#588964

Thanks for the response Christian! It sounds like you're saying my structure is not ideal and recommending that instead I use a repeating URL custom field if possible. I'll take a look into this now, as I'd like to start with best possible option. It sounds like I just need to work through this Toolset guide:

https://toolset.com/documentation/user-guides/using-custom-fields/

Using the new keywords you mentioned I also located a 2013 Toolset thread on the topic.
https://toolset.com/forums/topic/how-to-create-a-list-of-repeating-url-fields-with-text-as-link-instead-of-url/

I'll work through the documentation and try to get it set up. It may take some time (I'm a n00b) but your documentation is good and I'm glad to work through my own issues if I'm on the right track. Any specific advice for implementing this would be much appreciated but not necessary. I'll follow up on this thread to mark as resolved when I'm done.

Thanks again! Toolset is a revelation; love your products & support!

#588976

Great, I'll mark this ticket as pending an update from you for now. If you get stuck, or run into some documentation that doesn't make sense, feel free to let me know and I can provide some help.

#590411

Issue marked as resolved, thanks!