Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tab_shortcode($atts) {
- extract(shortcode_atts(array(
- 'category' => '',
- ), $atts, 'tab_shortcode'));
- $q = new WP_Query(
- array('posts_per_page' => '3', 'orderby' => 'menu_order', 'order' => 'DESC', 'post_type' => 'post_tab',)
- );
- global $post;
- $list = '
- <ul class="buttons-tab">
- ';
- while ($q->have_posts()) : $q->the_post();
- $tab_id = get_the_ID();
- $list .= '<li><a href="#' . $tab_id . '">' . get_the_title() . '</a></li>';
- endwhile;
- $list.= '
- </ul>
- <div class="tab-content" id="tab">';
- while ($q->have_posts()) : $q->the_post();
- $tab_id = get_the_ID();
- $arr = get_post_meta($post->ID, 'tab_details',true);
- $tab_item = '';
- foreach ($arr as $part) {
- $tab_item .= '<div class="text-icon-left">
- <span class="iconCircle fa ' . $part['icon'] . '"></span>
- <div class="text">
- <p>' . $part['text'] . '</p>
- </div>
- </div>';
- }
- $list .= '
- <div class="item tab-pane" data-hash="' . $tab_id . '">' . $tab_item . '</div>';
- endwhile;
- $list.= '
- </div>
- ';
- wp_reset_query();
- return $list;
- }
- add_shortcode('tab', 'tab_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement