首页特色图对齐方式可选

This commit is contained in:
Spirit 2019-09-05 19:24:03 +08:00
parent 13c95549d7
commit 66379fd944
2 changed files with 24 additions and 1 deletions

View File

@ -252,6 +252,17 @@ function optionsframework_options() {
'round' => __('圆形', ''), 'round' => __('圆形', ''),
'square' => __('方形', '') 'square' => __('方形', '')
)); ));
$options[] = array(
'name' => __('首页文章特色图对齐方式(仅对图文风格生效,默认左右交替)', 'akina'),
'id' => 'feature_align',
'std' => "alternate",
'type' => "radio",
'options' => array(
'left' => __('向左对齐', ''),
'right' => __('向右对齐', ''),
'alternate' => __('左右交替', '')
));
$options[] = array( $options[] = array(
'name' => __('默认文章特色图', 'options_framework_theme'), 'name' => __('默认文章特色图', 'options_framework_theme'),

View File

@ -11,7 +11,19 @@
//} //}
//add_filter('the_excerpt', 'custom_short_excerpt'); //add_filter('the_excerpt', 'custom_short_excerpt');
$i=0; while ( have_posts() ) : the_post(); $i++; $i=0; while ( have_posts() ) : the_post(); $i++;
$class = ($i%2 == 0) ? 'post-list-thumb-left' : ''; // 如果为偶数 switch (akina_option('feature_align')) {
case "left":
$class = 'post-list-thumb-left';
break;
case "right":
$class = '';
break;
case "alternate":
$class = ($i%2 == 0) ? 'post-list-thumb-left' : ''; // 如果为偶数
break;
default:
$class = ($i%2 == 0) ? 'post-list-thumb-left' : '';
}
if(has_post_thumbnail()){ if(has_post_thumbnail()){
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large'); $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
$post_img = $large_image_url[0]; $post_img = $large_image_url[0];