为什么不会出现快速代码出现在Elementor HTML小部件内?
我在Elementor的HTML小部件内有一些自定义的HTML,CSS和JS。在某个时候,我不得不用我在里面制作的短码插入一个DIV标签。快速代码在Elementor的短代码小部件中显示罚款,但在Elementor的HTML小部件中不显示。为什么会发生这种情况?
这是我在functions.php 中的短代码,除了Elementor的HTML窗口小部件外,它都可以使用
// Shortcode current username
function display_current_username () {
$user = wp_get_current_user();
$name = $user->user_firstname;
// If the $name var is empty, return the user_firstname property.
if ( $name === '' ) :
return $user->display_name;
endif;
return $name;
}
add_shortcode('display_name', 'display_current_username');
I have some custom html, css and js inside elementor's html widget. At some point I had to insert a div tag with a shortcode made by me inside. The shortcode displays fine in elementor's shortcode widget, but does not display inside elementor's html widget. Why does this happen ?
This is the shortcode I have in functions.php - It works everywhere except in elementor's html widget
// Shortcode current username
function display_current_username () {
$user = wp_get_current_user();
$name = $user->user_firstname;
// If the $name var is empty, return the user_firstname property.
if ( $name === '' ) :
return $user->display_name;
endif;
return $name;
}
add_shortcode('display_name', 'display_current_username');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用Elementor的短码小部件,并在短码之前或之后使用HTML元素。它将很好地工作。但是在HTML小部件内部,它将无法使用,因为小部件不适合运行快速代码。
在快捷代码窗口内使用它 -
You can use the shortcode widget of Elementor and use the html elements before or after the shortcode. It will work perfectly. But inside the HTML widget it will not work as the widget is not for running shortcode.
Use it like this inside the shortcode widget -
根据Elementor帮助页面(上次更新:2024年3月7日):
“在HTML小部件内部,您可以嵌入HTML,CSS,短代码,还包括JS脚本。”
https://elementor.com/help/help/html-widget/
As per the Elementor help pages (Last Update: March 7, 2024):
"Inside the HTML Widget you can embed HTML, CSS, Shortcodes, and also include JS scripts."
https://elementor.com/help/html-widget/
I can confirm that it's actually working for me.