Advertisement
xpeed

xxx

Feb 20th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. function tab_shortcode($atts) {
  2.     extract(shortcode_atts(array(
  3.         'category' => '',
  4.                     ), $atts, 'tab_shortcode'));
  5.     $q = new WP_Query(
  6.             array('posts_per_page' => '3', 'orderby' => 'menu_order', 'order' => 'DESC', 'post_type' => 'post_tab',)
  7.     );
  8.     global $post;
  9.     $list = '
  10.        <ul class="buttons-tab">
  11.        ';
  12.     while ($q->have_posts()) : $q->the_post();
  13.         $tab_id = get_the_ID();
  14.         $list .= '<li><a href="#' . $tab_id . '">' . get_the_title() . '</a></li>';
  15.     endwhile;
  16.     $list.= '
  17.                 </ul>
  18.           <div class="tab-content" id="tab">';
  19.     while ($q->have_posts()) : $q->the_post();
  20.         $tab_id = get_the_ID();
  21.  
  22.         $arr = get_post_meta($post->ID, 'tab_details',true);
  23.         $tab_item = '';
  24.  
  25.         foreach ($arr as $part) {
  26.             $tab_item .= '<div class="text-icon-left">
  27.                            <span class="iconCircle fa ' . $part['icon'] . '"></span>
  28.                            <div class="text">
  29.                                <p>' . $part['text'] . '</p>
  30.                            </div>
  31.                        </div>';
  32.         }
  33.         $list .= '
  34.            <div class="item tab-pane" data-hash="' . $tab_id . '">' . $tab_item . '</div>';
  35.     endwhile;
  36.     $list.= '
  37.           </div>
  38.        ';
  39.     wp_reset_query();
  40.     return $list;
  41. }
  42.  
  43. add_shortcode('tab', 'tab_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement