-
-
Save anonymous/06e9c71d7167fef52321 to your computer and use it in GitHub Desktop.
Image sort by category
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: Test | |
*/ | |
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' => 'formal' | |
) | |
) | |
); | |
$the_query = new WP_Query( $args ); | |
if ( $the_query->have_posts() ) { | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
$custom_url = get_post_meta( get_the_ID(), '_gallery_link_url', true ); | |
$custom_image_alt = get_post_meta( get_the_ID(), '_wp_attachment_image_alt', true ); | |
echo '<a href="' . $custom_url . '" target="_blank" title="' . $custom_image_alt . '" alt="' . $custom_image_alt . '" >' . wp_get_attachment_image( get_the_ID(), 'thumb' ) . '</a>'; | |
get_post_meta( get_the_ID(), '_wp_attachment_image_alt', true ); | |
} | |
} else { | |
// no attachments found | |
} | |
echo '<ul class="styles">'; | |
echo get_the_term_list( $post->slug, 'media_category','',' ',''); | |
echo '</ul>'; | |
?> | |
<form name="jump"> | |
<select name="menu"> | |
<?php | |
while ($the_query->have_posts()) : $the_query->the_post(); ?> | |
<option value="<?php the_permalink() ?>"><?php the_title(); ?></option> | |
<?php | |
endwhile; | |
?> | |
</select> | |
<input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="Go"> | |
</form> | |
<?php | |
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