30% Discount Get your Kallyas WordPress license Today for only $49! Or renew your support at $18 for extra 6 months. Shop Now

Open tabs with anchor links

Here’s a code snippet that should open vertical tabs using anchor links in the URL, eg: www.website.com/some-page/#open-3rd-tab . Simply paste this code into THEME options > Advanced > Custom JS :

// Javascript to enable link to tab
var zn_hash_url = document.location.toString();
if (zn_hash_url.match('#')) {
 jQuery('.tabbable a[data-toggle="tab"][href="#'+zn_hash_url.split('#')[1]+'"]').tab('show') ;

If you plan on adding into theme’s child theme’s custom JS file, make sure to wrap into document ready to have the DOM¬†ready for the job:

jQuery( document ).ready(function() {
  .. code..