卡片列表个数修改代码

2025-10-28 0 855
//卡片模式美化
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) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

轩玮博客 WordPress 卡片列表个数修改代码 http://blog.xuwbk.com/790.html

常见问题

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务