我想在wordpress中显示post,post1 floatLeft,post2 floatRight


I want to display post in wordpress, post1 floatLeft,post2 floatRight?

![在此输入图像描述][1]

"id="post-">

"rel="bookmark">

<div class="storyContent"><?php the_content(__('(more...)')); ?></div>

<?php if($counter%2 == 0){ echo "<div class='clear'></div>";} ?>
<?php $counter++; ?>

这是style.css

.foatRight{

浮动:右侧;

}

.foatLeft{

float:左;

}

.clear{

明确:两者皆有;

}

我想以这种方式显示我的帖子,请任何人帮助解决它,伙计。。

post1post2post3post4

<?php
$args = array( 'posts_per_page' => 10, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
$p=1;
foreach ( $myposts as $post ) {
    $class = ($p%2 == 0) ? "float-right" : "float-left";
    $p++;
    // Use $class in the div class
}

如果你想选择向左/向右浮动,你可以这样做:<p>可以是任何。。。<div>。。。<table>。。。

CSS

.pright{float:right;}
.pleft{float:left;}

HTML

 <p class="pleft">
    post1
    thumbnail   content
  </hr>
  </p>
 <p class="pright">
    post2
    thumbnail   content
  </hr>
  </p>