Grid Display Category Alternatives

Home Forums Ideas Grid Display Category Alternatives

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5041
    Eric
    Guest

    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”.

    #5042
    Eric
    Guest

    Wow, that code did NOT format nicely. Let me know if you want me to repost that…

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Ideas’ is closed to new topics and replies.
© 2024 DukaPress. All rights reserved.
Design By Madoido.