我已经创建了一个自定义帖子类型。为此,我使用了此代码
add_action( \'init\', \'broker_post_type\' );
function broker_post_type() {
register_post_type( \'new_broker\',
array(
\'labels\' => array(
\'name\' => __( \'Brands\' ),
\'singular_name\' => __( \'Brand\' )
),
\'public\' => true,
\'has_archive\' => true,
\'supports\' => array( \'title\', \'editor\', \'comments\', \'excerpt\', \'custom-fields\', \'thumbnail\' ),
)
);
}
现在,为了在一个页面中显示帖子类型品牌的所有特色图像,我使用了以下代码
function display_broker_posts() {
$args = array(
\'post_type\' => \'new_broker\',
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'posts_per_page\'=> -1,
);
$dee_bios = new WP_Query( $args );
if( $dee_bios->have_posts() ):
$dee_output = \'<div id="brokers-wrap">\';
$dee_output .= \'<div id="brokers-bg-wrap">\';
$dee_output .= \'<div class="brokers-content">\';
$dee_output .= \'<div class="brokers-left-content">\';
while ( $dee_bios->have_posts() ) : $dee_bios->the_post();
if( $dee_bios->current_post == 0 || ( $dee_bios->current_post % 2 ) == 0 ) {
$dee_output .= \'<div class="one-half first">\';
}
else {
$dee_output .= \'<div class="one-half">\';
}
$dee_output .= get_the_post_thumbnail( $dee_bios->post->ID,\'small\', \'bios\', array( \'class\' => \'alignleft\' ) );
$dee_output .= \'<span></span>\';
// $dee_output .= \'<p><strong>\' . get_the_title() . \',</strong> \' . get_the_content() . \'</p>\';
$dee_output .= \'</div><!--end .one-half-->\';
endwhile;
$dee_output .= \'<div class="clear"></div><!--clear all floats-->\';
$dee_output .= \'</div><!-- end #bios-->\';
endif;
wp_reset_postdata();
return $dee_output;
}
现在这个给出了结果。但结果是,我想要一些不同的东西。我想要那就说我有
16 posts in the Post
. 所以它会显示
first 10 posts in a different div and the rest 6 posts in a different div
. 有人能告诉我怎么做吗?任何帮助都将非常可观。谢谢