//卡片模式美化
CSF::createSection($prefix, array(
'label' => '当首页默认模式不为卡片模式时,此开关无效(仅对pc端有效)',
'id' => 'card',
'title' => '卡片模式美化',
'icon' => 'fa fa-linode',
'description' => '',
'fields' => array(
array(
'title' => '启用卡片模式美化',
'id' => 'card_switcher',
'class' => 'compact',
'type' => 'switcher',
'default' => false,
'desc' => '开启后,首页将以卡片模式展示,并可设置每行显示个数',
),
array(
'title' => '每行显示个数',
'id' => 'card_num',
'type' => 'number',
'default' => 4,
'min' => 3,
'max' => 5,
'step' => 1,
'unit' => '个',
'type' => 'spinner',
),
),
));
// 编写一个函数,用于卡片模式美化
function child_card_num_function() {
if (_child('card_num')) {
return _child('card_num');
} else {
return 3; // 默认值
}
}
function child_card_function() {
if (_child('card_num')) {
echo '<style>
@media only screen and (min-width: 1200px){.posts-item.card {
width: calc(' . (100.000000/_child("card_num")) . '% - ' . (80/_child("card_num")) . 'px);
}}</style>';
}
}
add_action('wp_head','child_card_function');
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)