• Hi everyone,

    Sorry if this has already been discussed but I couldn’t find anything about this subject, nor a plugin that would do it.

    I’m using a theme in which there is a shortcode for displaying some tabbed content, that looks like this :

    [tabs]
    [tab title=”Tab 1″] Tab 1 content [/tab]
    [tab title=”Tab 2″] Tab 2 content [/tab]
    [tab title=”Tab 3″] Tab 3 content [/tab]
    [/tabs]

    Currently you can only add text as a title for the tabs and I was wondering if it were possible to adapt it to show thumbnails instead ?

    Here is the code for the shortcodes :

    function gg_tabgroup( $atts, $content = null ) {
    	$tabs_count = 0;
            global $tabs_array, $tabs_count;
    	do_shortcode( $content );
    
    	$return = '';
    
    	if( is_array( $tabs_array ) ) {
    		$i = 0;
    		$x = 0;
    
    		$return .= '<div class="tabs"><ul class="tabs clearfix">';
    
    		foreach( $tabs_array as $tab ) {
    			$i++;
    			$return .= '<li class="' . ( ( $i == 1 ) ? 'first' : '' ) . '"><a title="' . $tab['title'] . '" href="#tab-' . $i . '">' . $tab['title'] . '</a></li>';
    		}
    
    		$return .= '</ul>';                
    
    		foreach( $tabs_array as $tab ) {
    			$x++;
    			$return .= '<div class="pane" id="tab-' . $x . '">' . do_shortcode( $tab['content'] ) .'</div>';
    		}
    
    		$return .= '</div>';
    
    		return $return;
    	}
    }
    add_shortcode('tabs', 'gg_tabgroup');
    
    function gg_tab( $atts, $content = null ) {
    	global $tabs_array, $tabs_count;
    
    	extract(shortcode_atts(array(
    		'title' => 'Title goes here'
    	), $atts));
    
    	$tabs_array[] = array(
    		'title' => $title,
    		'content' => do_shortcode( $content )
    	);
    
    	$tabs_count++;
    }
    add_shortcode('tab', 'gg_tab');

    If it’s too much coding, I will just use text tabs, but any hint as how to do this with images would be appreciated. Otherwise could you provide me a link to a plugin that adds this functionality ?

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

The topic ‘Add thumbnails to tabs’ is closed to new replies.