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' );
- $posttags = get_the_tags();
- if ($posttags) {
- foreach ($posttags as $tag) {
- str_replace('-','_',$tag->slug . ' ');
- }
- }
- echo '<aside class="work_item" data-id="id-' . get_the_ID() . '" data-type="' . $posttags . '">';
- 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 ' ' . get_post( get_post_thumbnail_id($post->ID) )->post_excerpt . ' ';
- echo '</li>';
- echo '</ul>';
- echo '<ul class="work_features">';
- echo '<li class="lightbox">';
- $attachment_id = $post->ID; // dynamic attachment ID
- $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array
- echo '<a class="work_lb tooltip" data-id="' . get_the_ID() . '" title="view in lightbox" href="' . $image_attributes[3] . '" rel="prettyPhoto[mixed]">';
- 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