I’m having trouble with
I can not link text or button to anything/ All buttons and text will not let me link them.
Working in
Wix Editor
Site link
What I’m trying to do
add a link to my text and buttons
What I’ve tried so far
I click on choose link and the window does not open to link to page, URL etc
Happens to all text and buttons and I have cleared my cache, deleted buttons and added new ones. I have buttons on other pages which I had to create on another site which I copied and pasted them over. However, this is only useful if I want to link to a URL and not a page within my site.
Alternatively, you could use code like this to set links for both button elements and text elements all at once, which can be really convenient. Feel free to give it a try if you’re interested!
import wixLocation from "wix-location";
$w.onReady(() => {
const elementLinks = {
text0: "https://amazon.com",
text1: "/page-1",
button1: "https://yahoo.co.jp"
};
setLinks(elementLinks);
});
function setLinks(elementLinks) {
for (const [id, url] of Object.entries(elementLinks)) {
$w(`#${id}`).onClick(() => wixLocation.to(url));
}
}
You need to change text0 and text1 to the IDs of the text elements on your site’s page, and likewise, button1 should be replaced with the ID of the button element on your site’s page. Of course, three elements won’t be enough, so you’ll need to add more element names and corresponding destination URLs as needed.
By the way, “/page-1” is also just an example to show how to navigate between pages within your site. Please check the URL slug of your own site’s page and replace it accordingly.