Grid Display Category Alternatives

Home Forums Ideas Grid Display Category Alternatives

This topic contains 1 reply, has 1 voice, and was last updated by  Eric 2 years, 8 months ago.

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

    Eric

    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 Reply

    Eric

    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)
Reply To: Grid Display Category Alternatives
Your information:




© 2014 DukaPress. All rights reserved.
Design By Madoido.