Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_shortcode('carousel_shortcode', 'carousel_shortcode');
  2.  
  3. function carousel_shortcode($atts) {
  4.     extract(shortcode_atts(array(
  5.         'title' => 'You may also like...',
  6.         'number_of_posts' => '',
  7.         'category' => ''
  8.     ), $atts));
  9.    
  10.  
  11.    
  12.     return '<h3>'. $title .'</h3><div class="list_carousel responsive"><ul id="foo2">' .
  13.             $args = array( 'numberposts' => $number_of_posts, 'category' => $category ) .
  14.             $recent_posts = wp_get_recent_posts( $args ) .
  15.             foreach( $recent_posts as $recent ){ .
  16.                 if ( has_post_thumbnail($recent["ID"])) { .
  17.                     echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' . get_the_post_thumbnail($recent["ID"], 'large') . '</a> .
  18.                     <a href="' . get_permalink($recent["ID"]) . '" class="carousel-post-title" title="Look '.esc_attr($recent["post_title"]).'" >' .   $recent["post_title"].'</a> </li>' .
  19.                 } .
  20.             } .
  21.             '</ul><div class="clearfix"></div><a id="prev2" class="prev" href="#"><</a><a id="next2" class="next" href="#">></a></div>';
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement