Question:
Can I display tags similar in function to blog tags using the cms tags field?
Product:
Wix Studio Editor
What are you trying to achieve:
I’d like to display the values in a cms tag field on a dynamic item page, so the user can click one and see a dynamic list of all the items in the cms that also have that tag or tags. The solution needs to support displaying multiple tags with their own button/link
What have you already tried:
Using a repeater with buttons linked to cms tag field. It only managed to display all the tags as one long button label
Thank you so much for taking the time to create this video!
Apologies for not explaining more clearly: I need these tags to display on the item page, not the list page. Clicking on a tag would take the user to a list page that was already filtered by that tag. See below for an example from a blog entry:
I’m glad found the video helpful. In this case, you might need to code it as clicking those tags redirects you to pages created by the blog app to posts filtered by those categories.
This is working for me to catch and redirect to another page if you want to use it as a starting point to redirect to a dynamic page set as /posts/${categoryName}
// This code automatically redirects users from '/blog/categories/{categoryName}' to '/posts/{categoryName}'
import wixLocation from 'wix-location';
$w.onReady(function () {
// Get the current URL path as an array
const path = wixLocation.path;
// Check if the path matches the pattern: ['blog', 'categories', '{categoryName}']
if (path.length === 3 && path[0] === 'blog' && path[1] === 'categories') {
const categoryName = path[2];
// Redirect to the new path
wixLocation.to(`/posts/${categoryName}`);
}
});