Advertisement
dalbeck

Portfolio 2

Sep 26th, 2013
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 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.  
  27.         $logoimg = wp_get_attachment_image( $image->ID, 'Work Gallery' );
  28.  
  29.         $t = wp_get_post_tags($parent_id);
  30.             $slugs = array();
  31.             foreach($t as $slug) {
  32.                 array_push($slugs, $slug->name);
  33.             }
  34.             $slugs = implode(', ', $slugs);
  35.                            
  36.             $posttags = get_the_tags();
  37.                 if ($posttags) {
  38.                     foreach ($posttags as $tag) {
  39.                         //str_replace('-','_', $tag->slug . ' ');
  40.                         str_replace(array('-', '&', ' '), array('&'. '&', '&'), $tag->slug);
  41.                     }
  42.                 }
  43.  
  44.             echo '<aside class="work_item" data-id="id-' . $parent_id . '" data-type="' . $slugs . '">';
  45.  
  46.                 echo '<ul>';
  47.  
  48.                     echo '<li>';
  49.  
  50.                         echo '<div class="img_wrap">';
  51.  
  52.                             echo $logoimg;
  53.  
  54.                         echo '</div>';
  55.  
  56.                         echo '<ul class="work_meta">';
  57.  
  58.                             echo '<li class="work_title">';
  59.  
  60.                                 echo ' ' . $parent_title . ' ';
  61.  
  62.                             echo '</li>';
  63.  
  64.                             echo '<li class="work_item_content">';
  65.  
  66.                                 echo ' ' . $attachment_title = get_the_title($attachment_id) . ' ';
  67.  
  68.                             echo '</li>';
  69.  
  70.                         echo '</ul>';
  71.  
  72.                         echo '<ul class="work_features">';
  73.  
  74.                             echo '<li class="lightbox">';
  75.  
  76.                                 $src = wp_get_attachment_image_src( $image->ID, 'full' );
  77.                                 $src = $src[0]; // Grabs only the URL ($src[1] = width of image, $src[2] = height of image)
  78.  
  79.                                 echo '<a class="work_lb tooltip works_gal" data-rel="prettyPhoto[mixed]" data-id="' . get_the_ID() . '" title="view in lightbox" href="' . $src . '">';
  80.  
  81.                                     echo 'Lightbox';
  82.  
  83.                                 echo '</a>';
  84.  
  85.                             echo '</li>';
  86.  
  87.                         echo '</ul>';
  88.  
  89.                     echo '</li>';
  90.  
  91.                 echo '</ul>';
  92.  
  93.             echo '</aside>';
  94.  
  95.         }
  96.         wp_reset_postdata();
  97.     }
  98. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement