Changing recipe links to open in the current tab
By default, the links within the recipe card are set to open in new tabs - this is the default manner as it helps your users keep the recipe open, while also browsing other pages / products on your site.
If you'd prefer to change this, you can add this custom Javascript script to your site (in the theme.js file, or via the Custom JS section in the Recipe Kit theme block):
document.addEventListener('DOMContentLoaded', function() { // Select the parent element by its ID var rkParent = document.getElementById('rk_parent'); // Check if the element exists to avoid errors in case it's not on the page if (rkParent) { // Select all <a> tags within the #rk_parent element var links = rkParent.querySelectorAll('a'); // Iterate over the NodeList of links and modify their target attribute links.forEach(function(link) { link.setAttribute('target', '_self'); }); } });
Save that, reload your theme, and your recipe links should all open in the current tab now!