/enhancedmediapost.php Secret
Last active
August 16, 2019 09:07
-
-
Save aristath/1a5cfda1b632bc1324b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: TheGuydedContributer | |
*/ | |
get_header(); | |
?> | |
<div id="main-content"> | |
<?php | |
$args = array( | |
'post_type' => 'attachment', | |
'post_status' => 'any', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'media_category', | |
'field' => 'slug', | |
'terms' => 'andytorres' | |
) | |
) | |
); | |
$the_query = new WP_Query( $args ); | |
if ( $the_query->have_posts() ) { | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
$image = wp_get_attachment_image_src( get_the_ID(), 'full' ); | |
echo '<a href="' . $image[0] . '">' . wp_get_attachment_image( get_the_ID(), 'full' ) . '</a>'; | |
} | |
} else { | |
// no attachments found | |
} | |
wp_reset_postdata(); | |
?> | |
</div> <!-- #main-content --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment