Skip to content

Instantly share code, notes, and snippets.

@GitFrankie
Last active October 3, 2017 14:04
Show Gist options
  • Save GitFrankie/7783775b09fd00abe8e0ab1f63e00b90 to your computer and use it in GitHub Desktop.
Save GitFrankie/7783775b09fd00abe8e0ab1f63e00b90 to your computer and use it in GitHub Desktop.
Custom Download Monitor List by Taxonomy
<div class="single-post-wrap">
<div class="container">
<?php //start by fetching the terms for the dlm_download_category taxonomy
$terms = get_terms( 'dlm_download_category', array(
'orderby' => 'count',
'showposts' => '999',
'hide_empty' => 1
) );
?>
<?php
// now run a query for each category - display results in alpha order
foreach( $terms as $term ) {
// Define the query
$args = array(
'post_type' => 'dlm_download',
'showposts' => '999',
'dlm_download_category' => $term->slug,
'order' => 'ASC',
'orderby' => 'title'
);
$query = new WP_Query( $args ); ?>
<h5 class="trigger"><?php echo $term->name; ?></h5>
<div class="toggle_container">
<table class="form-downloads" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<th>Document Title</th>
<th>Version</th>
<th>Link</th>
<th class="type">Type</th>
</tr>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<tr>
<td>
<strong><a class="document-link" href="<?php $dlm_download->the_download_link(); ?>"><?php echo $dlm_download->get_the_title(); ?></a></strong><br>
<div class="description"><?php echo $dlm_download->get_the_short_description(); ?></div>
</td>
<td class="version">Published: <?php $date = $dlm_download->get_the_file_date(); $date = date_create($date); echo date_format($date, 'F j, Y');?></td>
<td class="dl-btn">
<div class="dl-button"><a href="<?php $dlm_download->the_download_link(); ?>">Download</a></div>
<div class="dl-count"><?php echo $dlm_download->get_the_download_count(); ?> downloads</div>
</td>
<td class="type"><a href="<?php $dlm_download->the_download_link(); ?>"><img class="doc-icon" src="<?php bloginfo('template_url'); ?>/images/filetype-<?php echo $dlm_download->get_the_filetype(); ?>.svg" title="download the <?php echo $dlm_download->get_the_filetype(); ?>" alt="download the <?php echo $dlm_download->get_the_filetype(); ?>" border="0" /></a></td>
</tr>
<?php endwhile; echo '</tbody></table></div>'; wp_reset_postdata();} ?>
</div>
</div>
<!-- / page content -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment