Skip to content

Instantly share code, notes, and snippets.

@aristath
Forked from anonymous/enhanced media post
Last active August 16, 2019 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aristath/1a5cfda1b632bc1324b5 to your computer and use it in GitHub Desktop.
Save aristath/1a5cfda1b632bc1324b5 to your computer and use it in GitHub Desktop.
<?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