Php 我的Wordpress插件中的第二个快捷码参数未更改

Php 我的Wordpress插件中的第二个快捷码参数未更改,php,wordpress,Php,Wordpress,我有一个带有2个参数的短代码,标签和搜索按钮。标签1工作正常,但我的searchButton从未改变其值 我是如何在我的wordpress博客上写的 [expert-locator label="labl" searchButton="hzz"] 在我的代码中 add_shortcode('expert-locator', 'expert_locator_shortcode'); function expert_locator_shortcode( $atts ) { /*

我有一个带有2个参数的短代码,标签和搜索按钮。标签1工作正常,但我的searchButton从未改变其值

我是如何在我的wordpress博客上写的

[expert-locator label="labl" searchButton="hzz"]
在我的代码中

add_shortcode('expert-locator', 'expert_locator_shortcode');       

function expert_locator_shortcode( $atts ) {

/*
 * Custom search label and submit button from shortcode parameter
 */
extract( shortcode_atts( 
            array (
                'label' => "Enter skills you're looking for: ",
                'searchButton' => "Submit"
            ), 
            $atts )
);

//extract( $shortcode_params );

global $wpdb;

$authors = array();

//begin form 
expert_form_output( $label, $searchButton ); //function contained in functions.php
}

function expert_form_output( $label = "Enter skills you're looking for: ",
                         $searchButton = "Submit" ) {
?>
<form method="get">
    <label for="searchTerm"><?php echo $label ?></label>
    <input type="text" name="searchTerm" 
        value="<?php if (isset($_GET['searchTerm'])) echo $_GET['searchTerm']; ?>">
    <input type="submit" value="<?php echo $searchButton ?>">
</form>
<?php
}
add_-shortcode('expert-locator','expert_-locator_-shortcode');
功能专家\定位器\短代码($atts){
/*
*来自shortcode参数的自定义搜索标签和提交按钮
*/
摘录(短码_附件(
排列(
'label'=>“输入您需要的技能:”,
“搜索按钮”=>“提交”
), 
$atts)
);
//提取($shortcode_参数);
全球$wpdb;
$authors=array();
//开始形成
expert_form_output($label,$searchButton);//functions.php中包含的函数
}
功能专家表格输出($label=“输入您需要的技能:”,
$searchButton=“提交”){
?>
此问题是并且是由您在短代码名称中使用连字符引起的。您应该将连字符更改为下划线:

add_shortcode('expert_locator', 'expert_locator_shortcode');       
同样来自同一链接:

重要提示-不要将camelCase或大写字母用于
$atts
属性名称


因此,在查看了另一个答案中发布的代码后,我尝试将我的“submitButton”更改为“submitButton”,它工作了…

基本调试:
var_dump(shortcode_atts(..)
并查看调用的真正结果。@MarcB数组(2){[“label”]=>string(4)“label”[“searchButton”]=>string(6)“Submit”}就是我得到的“labl”是自定义的,“Submit”是默认值,即使我在博客中更改了参数,但更改了它…没有修复任何问题