Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $args = array(
- 'post_type' => 'attachment',
- 'posts_per_page' => -1,
- 'post_status' => 'any',
- 'post_parent' => null,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'post_tag',
- 'field' => 'slug',
- 'terms' => 'logo'
- )
- )
- );
- $images = get_posts( $args );
- if ( $images ) {
- foreach ( $images as $image ) {
- // Get the parent post ID
- $parent_id = $image->post_parent;
- // Get the parent post Title
- $parent_title = get_the_title( $parent_id );
- // Get the parent post permalink
- $parent_permalink = get_permalink( $parent_id );
- // Get image caption
- $logoimg = wp_get_attachment_image( $image->ID, 'Work Gallery' );
- $t = wp_get_post_tags($parent_id);
- $slugs = array();
- foreach($t as $slug) {
- array_push($slugs, $slug->name);
- }
- $slugs = implode(', ', $slugs);
- $posttags = get_the_tags();
- if ($posttags) {
- foreach ($posttags as $tag) {
- //str_replace('-','_', $tag->slug . ' ');
- str_replace(array('-', '&', ' '), array('&'. '&', '&'), $tag->slug);
- }
- }
- echo '<aside class="work_item" data-id="id-' . $parent_id . '" data-type="' . $slugs . '">';
- echo '<ul>';
- echo '<li>';
- echo '<div class="img_wrap">';
- echo $logoimg;
- echo '</div>';
- echo '<ul class="work_meta">';
- echo '<li class="work_title">';
- echo ' ' . $parent_title . ' ';
- echo '</li>';
- echo '<li class="work_item_content">';
- echo ' ' . $attachment_title = get_the_title($attachment_id) . ' ';
- echo '</li>';
- echo '</ul>';
- echo '<ul class="work_features">';
- echo '<li class="lightbox">';
- $src = wp_get_attachment_image_src( $image->ID, 'full' );
- $src = $src[0]; // Grabs only the URL ($src[1] = width of image, $src[2] = height of image)
- echo '<a class="work_lb tooltip works_gal" data-rel="prettyPhoto[mixed]" data-id="' . get_the_ID() . '" title="view in lightbox" href="' . $src . '">';
- echo 'Lightbox';
- echo '</a>';
- echo '</li>';
- echo '</ul>';
- echo '</li>';
- echo '</ul>';
- echo '</aside>';
- }
- wp_reset_postdata();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement