如何将短代码插入现有的 html 元素(wordpress)? [英] How to insert a shortcode to an existing html elements (wordpress)?
本文介绍了如何将短代码插入现有的 html 元素(wordpress)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在现有的 html 代码中插入一个短代码 [ajaxdomainchecker]
.
我尝试了以下代码,但显示错误.你能告诉我如何添加短代码吗?
语法错误:意外的标识符:
SyntaxError: missing ) after 参数列表
jQuery(' .acf-field-60po7a8eu9444 p.description').html('<?php echo do_shortcode("[ajaxdomainchecker]"); ?>');
语法错误:无效或意外令牌
jQuery(".acf-field-60po7a8eu9444 p.description").html("");
语法错误:意外令牌
jQuery('.acf-field-60f5d9a279544 p.description').html(<?php echo do_shortcode('[ajaxdomainchecker]'); ?>);
现有代码(使用 acf/frontend
创建):
<div class="acf-label"><label for="acf-field_60po7a8eu9444">输入信息</label><div class="acf-input"><p class="description">搜索并输入信息</p><!-- 如何在此处添加短代码?--><textarea id="acf-field_60po7a8eu9444";名称=acf[field_60po7a8eu9444]";行=8"></textarea>
解决方案
您对 do_shortcode() 命令的想法是正确的,但您可以像这样直接将其放入 PHP 文件中:
<?php echo do_shortcode("[ajaxdomainchecker]");?>
I need to insert a shortcode [ajaxdomainchecker]
into an existing html code.
I tried the following code but it shows error. Would you please let me know how to add the shortcode?
SyntaxError: Unexpected identifier:
<script>
jQuery(document).ready(function(){
var sessionName = '<?php echo do_shortcode("[ajaxdomainchecker]"); ?>';
jQuery(" .acf-field-60po7a8eu9444 p.description").html(sessionName);
});
</script>
SyntaxError: missing ) after argument list
jQuery(' .acf-field-60po7a8eu9444 p.description').html('<?php echo do_shortcode("[ajaxdomainchecker]"); ?>');
SyntaxError: Invalid or unexpected token
jQuery(" .acf-field-60po7a8eu9444 p.description").html("<?php echo do_shortcode('[ajaxdomainchecker]'); ?>");
SyntaxError: Unexpected token
jQuery('.acf-field-60f5d9a279544 p.description').html(<?php echo do_shortcode('[ajaxdomainchecker]'); ?>);
Existing code (created using acf/frontend
):
<div class="acf-field acf-field-textarea acf-field-60po7a8eu9444 elementor-repeater-item-b95d154" data-name="rtype_selection_desc" data-type="textarea" data-key="field_60po7a8eu9444">
<div class="acf-label">
<label for="acf-field_60po7a8eu9444">Enter Info</label>
</div>
<div class="acf-input">
<p class="description">Search and Enter Info</p>
<!-- how to add the short code here? -->
<textarea id="acf-field_60po7a8eu9444" name="acf[field_60po7a8eu9444]" rows="8"></textarea>
</div>
</div>
解决方案
You have the right idea with the do_shortcode() command, but you can just put it right into your PHP file like so:
<?php echo do_shortcode("[ajaxdomainchecker]"); ?>
这篇关于如何将短代码插入现有的 html 元素(wordpress)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文