0

i'm building an e-commerce store with the easy digital downloads plugin. I dont want to have one page with all of my products, what i want is to have for each product category a single page. what i have so far is a template page - edd-store-front.php, with the folowing wp_query code:

 $per_page = intval( get_theme_mod( 'bwpy_store_front_count', 9 ) );
$offset = $current_page > 0 ? $per_page * ( $current_page-1 ) : 0;
$product_args = array(
    'post_type'     => 'download',
    'posts_per_page'    => $per_page,
    'offset'        => $offset,
    'tax_query' => array(
     array(
     'taxonomy' => 'download_category',
     'field' => 'id',
     'terms' => '29'
     ),
        ),
);
$products = new WP_Query( $product_args );

in this case, the edd-store-front.php displays all the products with the category id '29'. as i wrote in my code. now, the easy-digital downloads has some shortcodes, which i can decide with them what products (downloads) i want to display. for example: "[downloads category="29"]" will display all the products with the category id '29'. In the wordpress page that refers to the the edd-store-front.php template, the shortcodes doesnt affect anything, only the template file (for some reason?). so, my question is how can i achieve with the wp_query a single template file for all the pages of the store, that will display a custom category, which will be decided at the wordpress page in the dashboard, using the shortcodes?

yoD
  • 41
  • 3
  • 11

1 Answers1

0

Is there a reason you are trying to use a 'page'? i.e wanting some specific page behavior?

You could just name your template file 'taxonomy-download_category.php' if you just want to style/layout the Digital Download products differently.

In that case you can change things like the posts_per_page using the_pre_get_posts filter. Or a custom Loop in that template.

If you need to use a 'page' you may consider adding a custom field for the category to display. You're right the shortcode won't do anything in this context.

squatchman
  • 99
  • 6
  • thanks @squatchman. the reason i wanted to use 'page' is only because i thought this would be the right way. all the store pages should behave the same and be styled the same, as well the different digital download. i want for example, if i have in my store 3 different types of digital downloads, so each type (category) would have it's own page, which will display only the related digital products. – yoD Nov 03 '17 at 16:29
  • Are you using the Advanced Custom Fields plugin? that would be an easy way to do it without much modification. – squatchman Nov 03 '17 at 17:44
  • I didn't use the acf plugin. now i checked this out but i'm a little confused. you mean that i can do it with the plugin alone? or to do it through the taxonomy-download_category.php? – yoD Nov 05 '17 at 14:10