Last active
April 24, 2020 17:48
-
-
Save pippinsplugins/2778895 to your computer and use it in GitHub Desktop.
sample Easy Digital Downloads Product Grid with Pagination
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 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(); ?> |
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
It has a problem.
Line 6 should be
Here is my fork https://gist.github.com/ahmadawais/e31b77d664f1be1f5842