Skip to content

Instantly share code, notes, and snippets.

@jayj jayj/gist:1306314
Created Oct 22, 2011

Embed
What would you like to do?
Part of tutorial on Jayj.dk
/**
* Format: box
*/
if ( 'box' == $format ) :
$meta = get_post_meta( $id, 'download', true );
$count_meta = get_post_meta( $id, 'download_count', true );
// Start content
ob_start();
?>
<div class="single-download" id="single-download-<?php echo intval( $id ); ?>">
<?php
// Get the title, either from shortcode or the title of the download
$title = ( $title ) ? $title : 'Download ' . $download->post_title;
// Append count to title
if ( $show_count === true )
$title .= ' (Downloaded ' . number_format( $count_meta ) . ' times)';
?>
<!-- Thumbnail -->
<?php if ( $thumbnail !== false && has_post_thumbnail( $id ) ) { ?>
<a href="<?php echo get_permalink( $id ); ?>" title="<?php echo esc_attr( $title ); ?>"><?php echo get_the_post_thumbnail( $id, 'thumbnail' ); ?></a>
<?php } ?>
<?php if ( ! empty( $content ) ) { ?>
<div class="download-text"><?php echo $content; ?></div>
<?php } ?>
<a href="<?php echo get_permalink( $id ); ?>" title="<?php echo esc_attr( $title ); ?>" class="download-link">Download</a>
<?php
// Show count
if ( $show_count === true )
echo '<span class="download-count">' . sprintf( __( 'Downloaded %s times', 'twentyeleven' ), number_format( $count_meta ) ) . '</span>';
?>
</div> <!-- .single-download -->
<?php
// Return the content
return ob_get_clean();
endif; // 'box' == $format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.