首页特色图对齐方式可选

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

@ -253,6 +253,17 @@ function optionsframework_options() {
'square' => __('方形', '')
));
$options[] = array(
'name' => __('首页文章特色图对齐方式(仅对图文风格生效,默认左右交替)', 'akina'),
'id' => 'feature_align',
'std' => "alternate",
'type' => "radio",
'options' => array(
'left' => __('向左对齐', ''),
'right' => __('向右对齐', ''),
'alternate' => __('左右交替', '')
));
$options[] = array(
'name' => __('默认文章特色图', 'options_framework_theme'),
'desc' => __('在未设置文章特色图的情况下展示的默认图像,留空则调用本地随机封面(要展示的图片放入 /wp-content/themes/Sakura/feature/gallery/ 目录)', 'options_framework_theme'),

View File

@ -11,7 +11,19 @@
//}
//add_filter('the_excerpt', 'custom_short_excerpt');
$i=0; while ( have_posts() ) : the_post(); $i++;
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()){
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
$post_img = $large_image_url[0];