Adding a title attribute into tab shortcode
-
Hey everyone!
I have a tab shortcode installed on a template, and it generates one of these ‘recent/popular/featured’ tabs into the template.
The shortcode is as follows:
function tabs_shortcode($atts, $content = null) { $output = '<div class="tabs">'; $output .= '<div class="tab-menu">'; $output .= '<ul>'; //Build tab menu $numTabs = count($atts); for($i = 1; $i <= $numTabs; $i++){ $output .= '<li><a href="#tab'.$i.'">'.$atts['tab'.$i].'</a></li>'; } $output .= '</ul>'; $output .= '<div class="clear"></div>'; $output .= '</div><!-- .tab-menu (end) -->'; $output .= '<div class="tab-wrapper">'; //Build content of tabs $tabContent = do_shortcode($content); $find = array(); $replace = array(); foreach($atts as $key => $value){ $find[] = '['.$key.']'; $find[] = '[/'.$key.']'; $replace[] = '<div id="'.$key.'" class="tab">'; $replace[] = '</div><!-- .tab (end) -->'; } $tabContent = str_replace($find, $replace, $tabContent); $output .= $tabContent; $output .= '</div><!-- .tab-wrapper (end) -->'; $output .= '</div><!-- .tabs (end) -->'; return $output; }
What I need to do is create an extra attribute in the shortcode, so the anchor tag also has a title field, for a short tooltip.
Any help would be greatly appreciated!
Felipe
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Adding a title attribute into tab shortcode’ is closed to new replies.