2016-03-24 14 views
0

こんにちは、私は現在、このプロジェクトにWordpressのマルチループとページネーション

bsearch

を働いている私は2スタイルポスト最初の2ポストのための1と最後の4ポストのために別のスタイルを作成します。

ここに私が使用しているコードがあります。

<?php 
    $args = array('posts_per_page' => 2, 'category' => 5); 
    $myposts = get_posts($args); 
    foreach ($myposts as $post) : setup_postdata($post); ?> 

// content of the first 2 post here // 

<?php endforeach; wp_reset_postdata();?> 

<?php 
    $args = array('posts_per_page' => 4, 'category' => 5,'offset' => 2); 
    $myposts = get_posts($args); 
    foreach ($myposts as $post) : setup_postdata($post); ?> 

// content of the last 4 post here // 

<?php endforeach; wp_reset_postdata();?> 

私は検索して、この方法でページのページ設定が機能しないことを知っていました。 しかし、私はいくつかの基本的なワードプレスとPHPのコーディングを知っている。

誰でもこの問題を解決するのに役立つことができますか?ここで

は、私はこれはトリックを行う必要がありますPSD

答えて

0
<?php $args = array('posts_per_page' => 2, 'category' => 5); 
$myposts = get_posts($args); 
$count = 1; 
if($myposts->have_posts()): while($myposts->have_post): $myposts->the post(); 
     if($count < 3){ 
//content and style of the first two post 
$count++; 
} 
else{ 
//content and style of the rest of the post 
$count++; 
} 
endwhile; 
endif; 
?> 

で作られたデザインです。

関連する問題