Skip to content

Instantly share code, notes, and snippets.

@aristath
Forked from anonymous/gist:06e9c71d7167fef52321
Last active August 29, 2015 14:10
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/f2435a9c29fd96ed0232 to your computer and use it in GitHub Desktop.
Save aristath/f2435a9c29fd96ed0232 to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: Test
*/
get_header();
?>
<div id="main-content">
<?php
$terms = ( isset( $_GET['styles'] ) ) ? $_GET['styles'] : 'formal';
$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 );
$categories = array();
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 );
$categories[] = wp_get_post_terms( get_the_ID(), 'media_category' );
}
}
?>
<ul class="styles">
<?php foreach ( $categories as $category ) : ?>
<a href="?style=<?php echo $category['slug']; ?>">
<?php echo $category['name']; ?>
</a>
<?php endforeach; ?>
</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