1

特定のカテゴリの各ループを「注目の画像」で交互にフロートさせたい。新しい投稿ごとに「注目の画像」がフロート(右側、左側)に変わるようにします。

次のコードを使用して、各投稿で奇数または偶数のクラスをプルします。

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

しかし、それを機能させることはできません!! 助けてください!

4

1 に答える 1

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;}
于 2012-04-18T13:47:28.990 に答える