Title: [Plugin: Section Widget] Keep same tab when switching pages
Last modified: August 19, 2016

---

# [Plugin: Section Widget] Keep same tab when switching pages

 *  [RichTWebGuy](https://wordpress.org/support/users/richtwebguy/)
 * (@richtwebguy)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/)
 * I made a section-widget with two tabs. When I switch pages section-widget always
   returns to first tab. Change this be changed?
 * Tab 2 shows a list of posts. Visitor clicks on first post, that page is displayed,
   then when they go to click on second post, section-widget is showing tab 1.
 * [http://wordpress.org/extend/plugins/section-widget/](http://wordpress.org/extend/plugins/section-widget/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [godfreykfc](https://wordpress.org/support/users/godfreykfc/)
 * (@godfreykfc)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/#post-1252845)
 * You might want to check this out: [http://jqueryui.com/demos/tabs/#option-cookie](http://jqueryui.com/demos/tabs/#option-cookie)(
   Warning: JavaScript/jQuery ahead..)
 *  [gravitydk](https://wordpress.org/support/users/gravitydk/)
 * (@gravitydk)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/#post-1252894)
 * I think you refer to this code element as the solution, yes?
    [http://jqueryui.com/demos/tabs/#…immediately_select_a_just_added_tab](http://jqueryui.com/demos/tabs/#…immediately_select_a_just_added_tab)
 * in which case, we stick that code within the plugin source code as instructed
   there?
 *  [gravitydk](https://wordpress.org/support/users/gravitydk/)
 * (@gravitydk)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/#post-1252899)
 * I worked out, with help of my own site reader, that this is the code to insert.
   I’m not sure into which file to put it into?
 *     ```
       var $tabs = $('#example').tabs();
       var selected = $tabs.tabs('option', 'selected'); // => 0
       ```
   
 *  [godfreykfc](https://wordpress.org/support/users/godfreykfc/)
 * (@godfreykfc)
 * [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/#post-1252904)
 * Hi, what you want to do is actually kind of complicated. In order to make a tab“
   stay selected” between different pages, you’d have to store that value somewhere
   in a browser cookie. The example you linked from above is for a different task,
   and the code you pasted in your last post is for reading the current selected
   tab’s ID, but it doesn’t store it anywhere or use it in any meaningful way.
 * To do what you need, you’ll need to load jquery.cookies.js (Download it from 
   [here](http://plugins.jquery.com/project/cookie)). And then you can add the following
   code in your theme JavaScript file:
 * `jQuery('.swt-wrapper').tabs('option', 'cookie', { expires: 30 });`
 * If you are not too comfortable with doing all that, I’d advise you to leave it
   as is unless the feature is mission critical to your site.
 * Godfrey

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘[Plugin: Section Widget] Keep same tab when switching pages’ is closed
to new replies.

 * 4 replies
 * 3 participants
 * Last reply from: [godfreykfc](https://wordpress.org/support/users/godfreykfc/)
 * Last activity: [16 years, 6 months ago](https://wordpress.org/support/topic/plugin-section-widget-keep-same-tab-when-switching-pages/#post-1252904)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
