WordPress.org

Ready to get started?Download WordPress

Forums

Show 2 Categories (1 post)

  1. pedropenido
    Member
    Posted 1 year ago #

    Hi there.
    I'm installing a boutique theme to my wordpress client site.
    In the home.php page I have the code below showing a "Boutique Special Offers" category, listed on the Theme Panel.

    But I need to show two different lists. The first can be the actual category, which is chosen from a dropbox in the Boutique Theme panel.

    But I copied and pasted the code, inside the comment lines <!--LINHA 2-->, where I need to show another product category.

    Can anybody here help me?

    <?php if (get_option('boutique_special_offers') == 'on') { ?>
    	<h3 class="offer-title" id="special-offers"><span><?php echo esc_html(get_option('boutique_special_offers_heading')); ?></span></h3>
    	<div id="special-items" class="clearfix">
    		<?php
    			$special_offers_args = array(
    				'showposts' => (int) get_option('boutique_special_offers_numposts'),
    				'cat' => get_cat_ID(get_option('boutique_special_offers_category'))
    			);
    
    			global $boutique_active_plugin_name;
    			if ( $boutique_active_plugin_name == 'wp_ecommerce' ){
    				$special_offers_term = get_term_by('name', get_option('boutique_special_offers_category'), 'wpsc_product_category');
    
    				$special_offers_args = array(
    					'post_type' => 'wpsc-product',
    					'showposts' => (int) get_option('boutique_special_offers_numposts'),
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'wpsc_product_category',
    							'field' => 'id',
    							'terms' => $special_offers_term->term_id
    						)
    					)
    				);
    			}
    
    			$i = 0;
    
    			$special_offers_query = new WP_Query($special_offers_args);
    		?>
    		<?php if ($special_offers_query->have_posts()) : while ($special_offers_query->have_posts()) : $special_offers_query->the_post(); ?>
    			<?php $i++; ?>
    			<div class="special-item<?php if ( $i % 5 == 0 ) echo ' last'; ?>">
    				<?php
    					$width = 137;
    					$height = 121;
    					$titletext = get_the_title();
    					$thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Offer');
    					$thumb = $thumbnail["thumb"];
    				?>
    				<a href="<?php the_permalink(); ?>">
    					<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>
    
    				</a>
    				<h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
    				<div class="et-links clearfix">
    					<a href="#<?php echo boutique_product_name('offer'); ?>" class="add-to-cart et-shop-item"><?php esc_html_e('Orçar','Boutique'); ?></a>
    					<a href="<?php the_permalink(); ?>" class="more-info"><?php esc_html_e('Info','Boutique'); ?></a>
    				</div> <!-- end .et-links -->
    				<?php do_action('boutique_special_offer'); ?>
    			</div> <!-- end .special-item -->
    		<?php endwhile; endif; wp_reset_postdata(); ?>
    	</div> <!-- end #special-items -->
    <?php } ?>
    
    <div id="main-content">
    
    <!-- LINHA 2 -->
    
    <?php if (get_option('boutique_special_offers') == 'on') { ?>
    	<h3 class="offer-title2" id="special-offers2" style="background:url(images/offer-title-bg.png) no-repeat;"><span>PRODUTOS GRÁFICOS</span></h3>
    	<div id="special-items" class="clearfix">
    		<?php
    			$special_offers_args = array(
    				'showposts' => (int) get_option('boutique_special_offers_numposts'),
    				'cat' => get_cat_ID(get_option('boutique_special_offers_category'))
    			);
    
    			global $boutique_active_plugin_name;
    			if ( $boutique_active_plugin_name == 'wp_ecommerce' ){
    				$special_offers_term = get_term_by('name', get_option('boutique_special_offers_category'), 'wpsc_product_category');
    
    				$special_offers_args = array(
    					'post_type' => 'wpsc-product',
    					'showposts' => (int) get_option('boutique_special_offers_numposts'),
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'wpsc_product_category',
    							'field' => 'id',
    							'terms' => $special_offers_term->term_id
    						)
    					)
    				);
    			}
    
    			$i = 0;
    
    			$special_offers_query = new WP_Query($special_offers_args);
    		?>
    		<?php if ($special_offers_query->have_posts()) : while ($special_offers_query->have_posts()) : $special_offers_query->the_post(); ?>
    			<?php $i++; ?>
    			<div class="special-item<?php if ( $i % 5 == 0 ) echo ' last'; ?>">
    				<?php
    					$width = 137;
    					$height = 121;
    					$titletext = get_the_title();
    					$thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,false,'Offer');
    					$thumb = $thumbnail["thumb"];
    				?>
    				<a href="<?php the_permalink(); ?>">
    					<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>
    
    				</a>
    				<h4 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
    				<div class="et-links clearfix">
    					<a href="#<?php echo boutique_product_name('offer'); ?>" class="add-to-cart et-shop-item"><?php esc_html_e('Orçar','Boutique'); ?></a>
    					<a href="<?php the_permalink(); ?>" class="more-info"><?php esc_html_e('Info','Boutique'); ?></a>
    				</div> <!-- end .et-links -->
    				<?php do_action('boutique_special_offer'); ?>
    			</div> <!-- end .special-item -->
    		<?php endwhile; endif; wp_reset_postdata(); ?>
    	</div> <!-- end #special-items -->
    <?php } ?>
    
    <!-- FIM LINHA 2 -->

Topic Closed

This topic has been closed to new replies.

About this Topic