Skip to content

Instantly share code, notes, and snippets.

@ahmadawais
Forked from pippinsplugins/edd_grid.php
Created June 23, 2015 10:54
Show Gist options
  • Save ahmadawais/e31b77d664f1be1f5842 to your computer and use it in GitHub Desktop.
Save ahmadawais/e31b77d664f1be1f5842 to your computer and use it in GitHub Desktop.
<?php get_header(); ?>
<div id="main-content" class="row store-template">
<div class="content clearfix">
<?php
$current_page = get_query_var('paged');
$per_page = get_option('posts_per_page');
$offset = $current_page > 0 ? $per_page * ($current_page-1) : 0;
$product_args = array(
'post_type' => 'download',
'posts_per_page' => $per_page,
'offset' => $offset
);
$products = new WP_Query($product_args);
?>
<?php if ($products->have_posts()) : $i = 1; ?>
<?php while ($products->have_posts()) : $products->the_post(); ?>
<div class="threecol product<?php if($i % 4 == 0) { echo ' last'; } ?>">
<a href="<?php the_permalink(); ?>">
<h2 class="title"><?php the_title(); ?></h2>
</a>
<div class="product-image">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('product-image'); ?>
</a>
<?php if(function_exists('edd_price')) { ?>
<div class="product-price">
<?php
if(edd_has_variable_prices(get_the_ID())) {
// if the download has variable prices, show the first one as a starting price
echo 'Starting at: '; edd_price(get_the_ID());
} else {
edd_price(get_the_ID());
}
?>
</div><!--end .product-price-->
<?php } ?>
</div>
<?php if(function_exists('edd_price')) { ?>
<div class="product-buttons">
<?php if(!edd_has_variable_prices(get_the_ID())) { ?>
<?php echo edd_get_purchase_link(get_the_ID(), 'Add to Cart', 'button'); ?>
<?php } ?>
<a href="<?php the_permalink(); ?>">View Details</a>
</div><!--end .product-buttons-->
<?php } ?>
</div><!--end .product-->
<?php $i+=1; ?>
<?php endwhile; ?>
<div class="pagination">
<?php
$big = 999999999; // need an unlikely intege
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, $current_page ),
'total' => $products->max_num_pages
) );
?>
</div>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
</div><!--end .content-->
</div><!--end #main-content.row-->
<?php get_footer(); ?>
@sasansss
Copy link

hi
how can i show my EDD downloads as products on my sahifa theme ?
i use sahifa theme and i have some downloads on my EDD plugins but my theme dosen't understand my downloads as product and i can't show my downloads as product in my theme's shop and my theme don't show my downloads categories on my shop and product's category
how can i fix this issue ? Please HELP me to fix it .
Thanks
awesomemotive/easy-digital-downloads#6468

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment