• Resolved anandmongol

    (@anandmongol)


    The following code gets all the respective information from all the categories, but kindly help me to get information from only one category, (ie:- category name is Promoted Coupon, ID is 12. I cant figure out how to code it.

    THANX IN ADVANCE

    <ul class="rr slides">
    <?php
    	$args = array(	);
    	$args['post_type'] = 'coupons';
    	$args['posts_per_page'] = 8;
    	$query = new WP_Query($args);
    	while($query->have_posts() ) : $query->the_post();
    	$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);
    	$thumbs = array();
    	$categories = get_the_category();
    	$thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    		if($categories) {
    		foreach($categories as $category) {
    		$image = get_option('taxonomy_' . $category->term_id);
    			if($image) {
    			if($thumb == '') {
    				$thumb = $image['custom_term_meta'];
    			        }
    				$category_id = $category->term_id;
    				}
    			}
    		}
    	$daysleft = round( ($date-time()) / 24 / 60 / 60);
    	?>
    	<li>
    	<div class="wrapper-3 item-thumb">
    		<div class="top">
    		<figure>
    		<a href="<?php echo get_category_link( $category_id );?>">
    		<img src="<?php echo aq_resize($thumb, 200, 140, true); ?>"     alt="<?php the_title();?>">
    		</a>
    		</figure>
    	<h2 class="alt"><a href="<?php the_permalink();?>"><?php truncate_title(15);?></a></h2>
    	</div>
    	<div class="bottom">
    	<?php if($discount != '') { ?>
    	<p class="value secondary"><?php echo $discount;?></p>
    		<?php } ?>
    		<h6>
    	<?php
    										if($date == '')
    	_e('VALID', 'Couponize');
    	else if($daysleft <= 0) 								_e('EXPIRED', 'Couponize');
    	else echo sprintf( _n('%d day left.', '%d days left.', $daysleft, 'Couponize'), $daysleft ); ?>
    		</h6>
    	</div>
    </div>
    </li>
    <?php endwhile; wp_reset_postdata();?>
    </ul>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get the information from only one category and display it’ is closed to new replies.