• Hi,

    I want to display certain categories first while displaying all the categories on the frontpage. Any idea is greatly appreciated.

    `
    <?php
    $paged = is_front_page() ? get_query_var( ‘page’ ) : get_query_var( ‘paged’ );
    $args[‘paged’] = $paged;
    $args[‘post_type’] = ‘coupons’;
    if(isset($_GET[‘sort’]) && $_GET[‘sort’] == ‘popular’) {
    $args[‘orderby’] = ‘comment_count’;
    $args[‘order’] = ‘ desc’;
    }
    elseif(isset($_GET[‘sort’]) && $_GET[‘sort’] == ‘thumbs’) {
    $args[‘gdsr_sort’] = ‘thumbs’;
    $args[‘sort_order’] = ‘ desc’;
    $args[‘meta_query’] = array(
    array(
    ‘key’ => ‘_single_date’,
    ‘value’ => strtotime(“now”),
    ‘compare’ => ‘>=’,
    ‘type’ => ‘UNSIGNED’
    )
    );
    }
    elseif(isset($_GET[‘sort’]) && $_GET[‘sort’] == ‘expiring’) {
    $args[‘meta_query’] = array(
    array(
    ‘key’ => ‘_single_date’,
    ‘value’ => strtotime(“now”),
    ‘compare’ => ‘>=’,
    ‘type’ => ‘UNSIGNED’
    )
    );
    $args[‘meta_key’] = ‘_single_date’;
    $args[‘orderby’] = ‘meta_value’;
    $args[‘order’] = ‘asc’;
    }
    if(isset($_GET[‘categories’]) || isset($_GET[‘min’]) ) {
    if(isset($_GET[‘categories’]) && count($_GET[‘categories’]) > 0)
    $args[‘category__in’] = $_GET[‘categories’];
    $min = (int)$_GET[‘min’];
    $max = (int)$_GET[‘max’];
    $minarg = strtotime(“now”) + $min * 86400; //converting days to timestamp
    $maxarg = strtotime(“now”) + $max * 86400; //converting days to timestamp
    $args[‘meta_query’] = array(
    array(
    ‘key’ => ‘_single_date’,
    ‘value’ => array( $minarg, $maxarg ),
    ‘compare’ => ‘BETWEEN’,
    ‘type’ => ‘UNSIGNED’
    )
    );
    }
    else {
    $categories = get_post_meta($post->ID, ‘_coupons_categories’, true);
    if($categories)
    $args[‘category__in’] = $categories;
    }
    query_posts($args);
    ?>

    <div class=”stripe-regular”></div>
    <div class=”stripe-regular”></div>

    <div class=”coupon-wrapper”>
    <div class=”coupon-result”>
    <?php _e(‘Нийт купон, Offers & Deals :’, ‘Couponize’);?>
    <span><?php echo $wp_query->found_posts . ‘ ‘;?></span>
    </div>
    <div class=”stripe-regular”></div>

    <?php
    if(have_posts() ) : while(have_posts() ) : the_post();
    $thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    $discount = get_post_meta($post->ID, ‘_single_discount’, true);
    $date = get_post_meta($post->ID, ‘_single_date’, true);
    $code = get_post_meta($post->ID, ‘_single_code’, true);
    $url = get_post_meta($post->ID, ‘_single_url’, true);
    $daysleft = round( ($date-time()) / 24 / 60 / 60);
    $categories = get_the_category();
    $category = ”;
    if($categories) {
    $category = $categories[0]->name;
    }
    ?>
    <div class=”coupon”>
    <?php if($thumb != ”) { ?>
    <div class=”coupon-top”>
    <figure>
    “><img src=”<?php echo aq_resize($thumb, 300, 200, true); ?>” alt=”<?php the_title();?>”>
    </figure>
    <div class=”coupon-title”>
    “><?php truncate_title(15);?>
    </div>
    </div>
    <?php } ?>
    <div class=”coupon-bottom”>
    <div class=”coupon-offer”>
    <?php echo substr($discount, 0, 15);?>
    </div>
    <div class=”coupon-date”>
    <?php
    if($date == ”)_e(‘Х?чинтэй’, ‘Couponize’);
    else if($daysleft <= 0) _e(‘Дууссан’, ‘Couponize’);
    else echo sprintf( _n(‘%d day left.’, ‘%d Хоног ?лдсэн.’, $daysleft, ‘Couponize’), $daysleft );
    ?>
    </div>
    </div>

  • The topic ‘priority while displaying displaying categories – certain categories first’ is closed to new replies.