Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义短代码无效_Php_Wordpress_Shortcode - Fatal编程技术网

Php 自定义短代码无效

Php 自定义短代码无效,php,wordpress,shortcode,Php,Wordpress,Shortcode,我第一次尝试做我自己的短码。我已经做了所有的事情,没有语法错误。谁能告诉我出了什么错吗?它不起作用了 我已经在function.php文件中实现了这段代码,Dreamweaver告诉我没有语法错误 function booknovelist_button( $atts ) { // Attributes extract( shortcode_atts( array( 'style' => 'rfc', 'link' => 'ww

我第一次尝试做我自己的短码。我已经做了所有的事情,没有语法错误。谁能告诉我出了什么错吗?它不起作用了

我已经在function.php文件中实现了这段代码,Dreamweaver告诉我没有语法错误

function booknovelist_button( $atts ) {
    // Attributes   
    extract( shortcode_atts( array( 
        'style' => 'rfc',
        'link' => 'www.booknovelist.com'
    ), $atts ) );

    $style  = '$atts[style]'; $choice = ' '; $choicehover = ' ';

    if ($style == 'rfc') {
        $choice='link to image';
        $choicehover='link to image';
    }; 

    if ($style == 'sn') {
        $choice='link to image';
        $choicehover='link to image';
    }

    if ($style == 'pon') {
        $choice='link to image';
        $choicehover='link to image';
    }

    if ($style == 'amazon') {
        $choice='link to image';
        $choicehover='link to image'; 
    }

    echo '<div><a href="',$link,'"><img src="',$choice,'" onmouseover="this.src="',$choicehover,'"" onmouseout="this.src="',$choice,'""></a></div> ' ; } 
}

add_shortcode ( 'bn_btn', 'booknovelist_button' );
功能书小说家按钮($atts){
//属性
提取(短码)附件(数组(
'style'=>'rfc',
“链接”=>“www.booknoviter.com”
)美元(附件);;
$style='$atts[style]';$choice='';$choicehover='';
如果($style=='rfc'){
$choice='linktoimage';
$choicehover='linktoimage';
}; 
如果($style=='sn'){
$choice='linktoimage';
$choicehover='linktoimage';
}
如果($style=='pon'){
$choice='linktoimage';
$choicehover='linktoimage';
}
如果($style=='amazon'){
$choice='linktoimage';
$choicehover='linktoimage';
}
回音“;}
}
添加快捷码('bn_btn','bookwriter_按钮');

您应该查看的文档并查看示例。您应该返回短代码输出的内容

function footag_func( $atts ) {
    return "foo = {$atts['foo']}";
}
add_shortcode('footag', 'footag_func');
因此,你不应该重复你的div,而应该返回它

您的代码似乎还有其他语法错误