Hi,
Thank you for contacting us and I'd be happy to assist.
To confirm, you'd like to show the taxonomy terms attached to the current post, so that if it is a specific term (for example "Tag 2"), it should link to a special page ( for example: {yourwebsite.com}/special-page ). And if it is any other term, it should link to a common or generic page ( for example: {yourwebsite.com}/normal-page ).
If my understanding is correct, you'll need to use a custom shortcode for this:
function process_tax_links_func( $atts, $content = null ) {
$a = shortcode_atts( array(
'sep' => ', ',
'term' => '',
'term_link' => '',
'generic_link' => '',
), $atts );
$content = apply_filters('the_content',$content);
if(!empty($content)) {
$final_content = array();
$content_arr = explode($a['sep'], $content);
for ($i=0; $i < sizeof($content_arr) ; $i++) {
if($content_arr[$i] == $a['term']) {
$final_content[] = '<a href="'.$a['term_link'].'">'.$content_arr[$i].'</a>';
}
else
{
$final_content[] = '<a href="'.$a['generic_link'].'">'.$content_arr[$i].'</a>';
}
}
return implode($a['sep'], $final_content);
}
}
add_shortcode( 'process_tax_links', 'process_tax_links_func' );
The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.
After that, you'll be able to use this new shortcode in your content template like this, inside a "Fields and Text" block:
[process_tax_links sep=", " term="Tag 2" term_link="{yourwebsite.com}/special-page" generic_link="{yourwebsite.com}/normal-page"][wpv-post-taxonomy type="post_tag" format="name"][/process_tax_links]
Please note how the original taxonomy shortcode ( [wpv-post-taxonomy type="post_tag" format="name"] ) is enclosed in the new shortcode, which will give the comma-separated list of current post's term names from the "post_tag" taxonomy, which you can change based on your target taxonomy.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-taxonomy )
And then the "sep" attribute tells which separator is being used between the term names, "term" tells about the target special term name to look out for, and the "term_link" and "generic_link" attributes, represent the special term's and the generic term's links, respectively.
I hope this helps and please let me know if any point is not clear.
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar