You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Elementor CHOOSE控件前缀类%s字符串格式问题求助

Fixing Elementor CHOOSE Control Prefix Class Issue

Hey, let's get that prefix_class problem sorted out for your Elementor CHOOSE control. The issue here boils down to how Elementor handles the prefix_class parameter specifically for the CHOOSE control type.

Looking at your code, you added %s to the prefix_class value—but Elementor's CHOOSE control doesn't use that placeholder. Instead, it automatically appends the selected option's value directly to the prefix string you provide. That's why you're seeing etlms-author-layout-%sleft instead of the desired etlms-author-layout-left: the %s is being treated as literal text, then the option value gets tacked on at the end.

The Fix

Simply remove the %s from your prefix_class definition. Here's the corrected code:

$this->add_responsive_control( 'course_author_layout', [
    'label' => __('Layout', 'text-domain'),
    'type' => Controls_Manager::CHOOSE,
    'options' => [
        'left' => [
            'title' => __('Left', 'text-domain'),
            'icon' => 'fa fa-long-arrow-left',
        ],
        'up' => [
            'title' => __('Center', 'text-domain'),
            'icon' => 'fa fa-long-arrow-up',
        ],
    ],
    'prefix_class' => 'etlms-author-layout-', // No more %s here
    'default' => 'left',
] );

Why This Works

For the CHOOSE control, Elementor takes the string you set in prefix_class and concatenates it with the selected option's key (in your case, left or up). So with etlms-author-layout- as the prefix, selecting left will generate the class etlms-author-layout-left, which matches your expected result.

Just a quick note: This behavior is specific to the CHOOSE control. Other control types like SELECT might require the %s placeholder, but CHOOSE handles the value appending automatically.

内容的提问来源于stack exchange,提问作者SK Shewa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 18:02:27