Advertisement
firozpbn

Wordpress dynamic code for Bootstrap 3 Accordion

Nov 26th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. function accordion_list_shortcode($atts){
  2.     extract( shortcode_atts( array(
  3.         'category' => '',
  4.         ), $atts, 'accordion-content' ) );
  5.     $q = new WP_Query(
  6.         array('posts_per_page' => '5', 'post_type' => 'accordion_items', 'accordion_category' => $category)
  7.         );
  8.     $list = '<dl class="accordion toggles">';
  9.         while($q->have_posts()) : $q->the_post();
  10.         $idd = get_the_ID();
  11.         $list .= '
  12.  
  13.  
  14.        <dt class="accordion-trigger"><i class="fa fa-facebook"></i>'.get_the_title().'</dt>
  15.        <dd class="accordion-content">
  16.            <p>'.get_the_content().'</p>
  17.        </dd>
  18.  
  19.  
  20.        ';
  21.         endwhile;
  22.     $list.= '</dl>';
  23.     wp_reset_query();
  24.     return $list;
  25. }
  26. add_shortcode('accordion_list', 'accordion_list_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement