首先显示某些类别,然后显示其余类别。 (WordPress的)

时间:2016-05-23 00:18:09

标签: php wordpress loops categories

我想要这样显示。

Example

我想在主页上优先列出优惠券 - 首先显示注册用户的优惠券然后逐渐免费用户上传的优惠券。 注意: - 我尝试使用2个循环并且它没有列出我想要的方式:( -

<?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; ?>

0 个答案:

没有答案