Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joviczarko/d9e2ff8a6c5bb6887070fd63d09a9ffd to your computer and use it in GitHub Desktop.
Save joviczarko/d9e2ff8a6c5bb6887070fd63d09a9ffd to your computer and use it in GitHub Desktop.
Easy Digital Downloads - Download Grid Loop Function
function get_edd_posts($per_page, $order, $category = '', $exclude_category = '') {
$exclude_categories = explode(',', $exclude_category);
$product_args = array(
'tax_query' => array (
array(
'taxonomy' => 'download_category', // Download Category
'terms' => $exclude_categories, // Download Category Exclusions
'field' => 'slug', // Term Slug
'operator' => 'NOT IN' // Selection operator - use IN to include, NOT IN to exclude
),
),
'post_type' => 'download', // Post Type EDD
'download_category' => $category, // Download Category
'posts_per_page' => $per_page, // Posts Per Page
'order' => $order // Order By
);
$products = new WP_Query($product_args);
while ($products->have_posts()) : $products->the_post();
the_permalink(); // Download Permalinks
the_post_thumbnail(); // Download Image
the_title(); // Download Title
get_edd_parent_category(); // Checkout my Gist For This Function
get_download_price(); // Checkout my Gist For This Function
endwhile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment