//卡片模式美化
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');
© 版权声明
THE END














暂无评论内容