I found myself in a bind tonight when I wanted to display ALL of the DukaPress items. Not wanting to completely ruin the dpsc_pnj_grid_display()
function, I added 3 lines to allow for a NULL-type category variable.
Initial code:
... } else {
$order_string = 'orderby=rand&';
}
$products = get_posts($order_string . 'numberposts=' . $per_page . '&post_type=' . $type . '&meta_key=price' . $fcategory . $offset);
if (is_array($products) && count($products) > 0) {
...
Altered code:
... } else {
$order_string = 'orderby=rand&';
}
// Filter category argument. If the category is "ignore", just display ALL 'duka' types.
if($category == 'ignore') $fcategory = '';
else $fcategory = '&category='.$category;
$products = get_posts($order_string . 'numberposts=' . $per_page . '&post_type=' . $type . '&meta_key=price' . $fcategory . $offset);
if (is_array($products) && count($products) > 0) {
...
All this does is remove the category argument from the get_posts()
call if the shortcode category is set to “ignore”.