Switch Layouts Tabs using URL Parameter

Dynamically switch Layouts Tab options using a url parameter.

jQuery("document").ready(function() {
 jQuery.urlParam = function(name){
	var results = new RegExp('[?&]' + name + '=([^&#]*)').exec(window.location.href);
	return results[1] || 0;
}
    setTimeout(function() {
          if(jQuery.urlParam('tab') == 2){
          jQuery(".nav-tabs li:nth-child(2) a").click();
          }else if(jQuery.urlParam('tab') == 3){
              jQuery(".nav-tabs li:nth-child(3) a").click();
          }
    }, 10);
});

To use this ensure that you are on a page that has the Layouts Tabs section. Notice Layouts uses 2 classes for the tabs.
If you are using the Buttons option you will need to use “.nav-pills” and for the regular tabs “.nav-tabs”

Example use case “mytesturl/somepage?tab=2” will select tab 2 when the page is loaded instead of defaulting to tab 1.
Forum Link -> https://wp-types.com/forums/topic/static-links-to-specific-tab-in-the-tabs-layout-element/


Let us know if this snippet is not working for you:

This snippet doesn’t work
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments