2012-04-18 36 views
1

我希望特定類別上的每個循環在「特色圖像」上交替浮動。這樣每個新帖子的「精選圖片」都會浮動(右側,左側)。WordPress的,特色圖像上的交替浮動

我用如下因素代碼拉動每個崗位奇數或偶數類,

<?php query_posts('showposts=5&cat=5,'); if (have_posts()) : ?> 
<?php $c = 0; ?> 
<?php if (have_posts()) : ?> 
<?php while (have_posts()) : the_post(); ?> 
     <div <?php post_class((++$c % 2 === 0) ? 'odd' : 'even'); ?>> 
     <h2 class="entry-title"><a>" title="<?php printf(esc_attr__('Permalink to %s', 'twentyten'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 
<div class="featuredImage"> 
       <?php the_post_thumbnail('medium'); ?> 
     </div> 
    </div> 
<?php endwhile; ?> 
<?php endif; ?> 
<?php endif; wp_reset_query();?> 

然後我試圖改變「特色形象」的浮動對不同崗位類別的CSS(奇數或偶數)。硒例如,

.even { width:650px; height:250px; background-color: #000;} 

.odd{ width:650px; height:250px; background-color: #616161;} 
.odd, .featuredImage{ float:left;} 
.even, .featuredImage{ float:right;} 

我的例子,http://fskador.se/myPerformanceLast/?page_id=49

,但不能得到它的工作!請幫忙!

回答

0

錯誤

<h2 class="entry-title"><a>" title="<?php printf(esc_attr__('Permalink to %s', 'twentyten'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 

更正

<h2 class="entry-title"><a title="<?php printf(esc_attr__('Permalink to %s', 'twentyten'), the_title_attribute('echo=0')); ?>" rel="bookmark"><?php the_title(); ?></a></h2> 

CSS

錯誤

.odd, .featuredImage{ float:left;} 
.even, .featuredImage{ float:right;} 

更正

div.odd .featuredImage{ float:left;} 
div.even .featuredImage{ float:right;} 

或者

.odd .featuredImage{ float:left;} 
.even .featuredImage{ float:right;}