Link to CMS FAQ Item with URL Search Parameters

How to Link to and open CMS collections (FAQ Accordion, etc.) using URL search parameters

Watch the Tutorial on YouTubeGet the Project Cloneable

Inside <head> tag

Inside </body> tag

<script>
// On the page with outbound links
window.Webflow ||= [];
window.Webflow.push(() => {
  const links = document.querySelectorAll(".link");
  console.log(links);

  links.forEach((link, index) => {
    link.href += `?tabNumber=${index}#faqs`; // #faqs is section id
  });
});
</script>
<script>
// On the page with your CMS Collection
window.Webflow ||= [];
window.Webflow.push(() => {
  let url = new URL(window.location);
  let tabNumber = url.searchParams.get("tabNumber");
  let questionElements = document.querySelectorAll(".faq1_question");
  if (!tabNumber || !questionElements) {
    return;
  }

  questionElements[tabNumber].click();
});
</script>