Advertisement
dalbeck

Template

Sep 27th, 2013
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.22 KB | None | 0 0
  1. <?php
  2.     $args = array(
  3.         'post_type' => 'attachment',
  4.         'posts_per_page' => -1,
  5.         'post_status' => 'any',
  6.         'post_parent' => null,
  7.         'tax_query' => array(
  8.             array(
  9.                 'taxonomy' => 'post_tag',
  10.                 'field' => 'slug',
  11.                 'terms' => 'logo'
  12.             )
  13.         )
  14.     );
  15.  
  16. $images = get_posts( $args );
  17. if ( $images ) {
  18.     foreach ( $images as $image ) {
  19.         // Get the parent post ID
  20.         $parent_id = $image->post_parent;
  21.         // Get the parent post Title
  22.         $parent_title = get_the_title( $parent_id );
  23.         // Get the parent post permalink
  24.         $parent_permalink = get_permalink( $parent_id );
  25.         // Get image caption
  26.         $logoimg = wp_get_attachment_image( $image->ID, 'Work Gallery' );
  27.  
  28.         $t = wp_get_post_tags($parent_id);
  29.             $slugs = array();
  30.             foreach($t as $slug) {
  31.                 array_push($slugs, $slug->name);
  32.             }
  33.             $slugs = implode(', ', $slugs);
  34.  
  35.             $posttags = get_the_tags();
  36.                 if ($posttags) {
  37.                     foreach ($posttags as $tag) {
  38.                         //str_replace('-','_', $tag->slug . ' ');
  39.                         str_replace(array('-', '&', ' '), array('&'. '&', '&'), $tag->slug);
  40.                     }
  41.                 }
  42.  
  43.             echo '<aside class="work_item" data-id="id-' . $parent_id . '" data-type="' . $slugs . '">';
  44.  
  45.                 echo '<ul>';
  46.  
  47.                     echo '<li>';
  48.  
  49.                         echo '<div class="img_wrap">';
  50.  
  51.                             echo $logoimg;
  52.  
  53.                         echo '</div>';
  54.  
  55.                         echo '<ul class="work_meta">';
  56.  
  57.                             echo '<li class="work_title">';
  58.  
  59.                                 echo ' ' . $parent_title . ' ';
  60.  
  61.                             echo '</li>';
  62.  
  63.                             echo '<li class="work_item_content">';
  64.  
  65.                                 echo gds_get_excerpt($image->ID);
  66.  
  67.                             echo '</li>';
  68.  
  69.                         echo '</ul>';
  70.  
  71.                         echo '<ul class="work_features">';
  72.  
  73.                             echo '<li class="lightbox">';
  74.  
  75.                                 $src = wp_get_attachment_image_src( $image->ID, 'full' );
  76.                                 $src = $src[0]; // Grabs only the URL ($src[1] = width of image, $src[2] = height of image)
  77.  
  78.                                 echo '<a class="work_lb tooltip works_gal" data-rel="prettyPhoto[mixed]" data-id="' . get_the_ID() . '" title="view in lightbox" href="' . $src . '">';
  79.  
  80.                                     echo 'Lightbox';
  81.  
  82.                                 echo '</a>';
  83.  
  84.                             echo '</li>';
  85.  
  86.                         echo '</ul>';
  87.  
  88.                     echo '</li>';
  89.  
  90.                 echo '</ul>';
  91.  
  92.             echo '</aside>';
  93.  
  94.         }
  95.         wp_reset_postdata();
  96.     }
  97. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement