To show certain categories first, and then the rest of the categories. (WordPress)

I wanted to display like this.

Example

Read More

I want the priority listing of coupons on the homepage – first display of registered user’s coupons then gradually free user’s uploaded coupons.
Note:- I try to use 2 loops and it’s is not listing the way I want 🙁 –

<?php
        $paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
        $args['paged'] = $paged;
        $args['post_type'] = 'coupons'; 
        $categories = get_post_meta($post->ID, '_coupons_categories', true);
        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 
            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);  
        ?>
        <div class="coupon">
            <?php if($thumb != '') { ?>
                <div class="coupon-top">
                    <figure>
                        <a href="<?php the_permalink();?>"><img src="<?php echo aq_resize($thumb, 300, 200, true); ?>" alt="<?php the_title();?>"></a>
                    </figure>
                    <div class="coupon-title">
                        <a href="<?php the_permalink();?>"><?php truncate_title(25);?></a>
                    </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>
        </div>
        <?php endwhile; ?>

Related posts

Leave a Reply