Advertisement
Guest User

group shortcode

a guest
May 16th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1.  
  2. function get_celebrities_by($atts, $content = null) {
  3.  
  4.     extract( shortcode_atts( array( 'tags' => 'None' ), $atts ) );
  5.  
  6.     $display = '';
  7.     $args = array( 'tag_slug__and' => $tags, 'posts_per_page' => 28, 'caller_get_posts'=> 1, 'numberposts' => 1 );
  8.     $postslist = get_posts( $args );
  9.    
  10.     if($postslist) {
  11.    
  12.         foreach($postslist as $post) {
  13.             $display .= generate_caracters($post);
  14.         }
  15.    
  16.     } else {
  17.         $display .= '<p>No celebrities found.</p>';
  18.     }
  19.    
  20.    
  21.     return $display;
  22.  
  23. }
  24.  
  25. function generate_caracters($post) {
  26.  
  27.     $gen = '<article id="post-'.$post->ID.'" class="home-thumb">';
  28.         $short_title = get_post_meta($post->ID, '_hollowverse-pa-data', true);
  29.         $short_title = $short_title->short_title;
  30.     $gen .= '<a href="'.get_permalink($post->ID).'" title=" '.get_post_meta(get_post_thumbnail_id( $post->ID ) , '_wp_attachment_image_alt', true).' " rel="bookmark">';
  31.     $gen .= '<div class="margin-2px">'.get_the_post_thumbnail( $post->ID, 'thumbnail' ).'</div>';
  32.     $gen .= '<h1>'.$short_title.'</h1></a>';
  33.     $gen .= '</article><!-- #post-'.$post->ID.'-->';
  34.    
  35.     return $gen;
  36.  
  37. }
  38.  
  39. add_shortcode( 'group', 'get_celebrities_by' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement