From 66379fd94433899d07b133ba9890f961888bd3dd Mon Sep 17 00:00:00 2001 From: Spirit Date: Thu, 5 Sep 2019 19:24:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=89=B9=E8=89=B2=E5=9B=BE?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E6=96=B9=E5=BC=8F=E5=8F=AF=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- options.php | 11 +++++++++++ tpl/content-thumb.php | 14 +++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/options.php b/options.php index 7d51f10..75f6d28 100644 --- a/options.php +++ b/options.php @@ -252,6 +252,17 @@ function optionsframework_options() { 'round' => __('圆形', ''), 'square' => __('方形', '') )); + + $options[] = array( + 'name' => __('首页文章特色图对齐方式(仅对图文风格生效,默认左右交替)', 'akina'), + 'id' => 'feature_align', + 'std' => "alternate", + 'type' => "radio", + 'options' => array( + 'left' => __('向左对齐', ''), + 'right' => __('向右对齐', ''), + 'alternate' => __('左右交替', '') + )); $options[] = array( 'name' => __('默认文章特色图', 'options_framework_theme'), diff --git a/tpl/content-thumb.php b/tpl/content-thumb.php index 76e36af..aabeb6b 100644 --- a/tpl/content-thumb.php +++ b/tpl/content-thumb.php @@ -11,7 +11,19 @@ //} //add_filter('the_excerpt', 'custom_short_excerpt'); $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()){ $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large'); $post_img = $large_image_url[0];