WordPress:将短代码添加到连接变量中

时间:2014-05-01 08:32:05

标签: php wordpress shortcode

我试图完成这项工作,但它无法正常工作。这段代码有什么问题?

add_filter( 'the_content', 'addslider_hook' );
function addslider_hook ( $content ) {

    if ( is_page('outsourced') ) {
        $slide = '[rev_slider outsourced]';
        $hook_slide = do_shortcode( $slide );

        $content .= "<div class='page-slider'>";
        $content .= $hook_slide;
        $content .= "</div>";
    } 
    return $content;
} 

1 个答案:

答案 0 :(得分:0)

你在代码的底部有一个额外的}。你可以试试这个

if ( is_page('outsourced') ) {      
    $content .= "<div class='page-slider'>";
    $content .= do_shortcode('[rev_slider outsourced]');
    $content .= "</div>";
    echo $content;
    }