嗨,我目前正在做这个项目
bsearch
我想创建两个风格的帖子,一个用于前2个帖子,另一个用于后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();?>
我搜索了一下,知道这样页面分页就不起作用了。但我只知道一些基本的wordpress和php编码。
有人能帮我解决这个问题吗?
这是我在PSD 中所做的设计
<?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;
?>
这应该奏效。