0

I am learning how to make wordpress theme. I am doing pretty well. Now I want to make shortcodes. But is is showing Parse error: syntax error, unexpected '}' in E:\xampp\htdocs\wordpress\wp-content\themes\freedom\shortcodes.php on line 17 . I still don't know what is the problem. Here is the code .

<?php

function slider_function( $atts ) {
    $atts = extract( shortcode_atts( 
                    array( 
                        'tittle'=>'', 
                        'description'=>'',
                        'button'=>'',
                        'button_url'=>''
                    ),$atts ) );
    return '
    <div class="slider">
        <h1>"' . $atts['tittle'] . '"</h1>
        <h2>"' . $atts['tittle'] . '"</h2>
        <a href="' . $atts['tittle'] . '" class="btn-modern text-center"></a>
    </div>'
}

add_shortcode( 'slider','slider_function' );

?>

2 Answers2

1

Take a look at this code how shortcode works and look at your code what returning.

function bartag_func( $atts ) {
    $a = shortcode_atts( array(
        'foo' => 'something',
        'bar' => 'something else',
    ), $atts );

    return "foo = {$a['foo']}";
}
add_shortcode( 'bartag', 'bartag_func' );
Sohail Qureshi
  • 689
  • 11
  • 24
1

You forgot a semicolon /div>';.

function slider_function( $atts ) {
$atts = extract( shortcode_atts( 
                array( 
                    'tittle'=>'', 
                    'description'=>'',
                    'button'=>'',
                    'button_url'=>''
                ),$atts ) );
return '
<div class="slider">
    <h1>"' . $atts['tittle'] . '"</h1>
    <h2>"' . $atts['tittle'] . '"</h2>
    <a href="' . $atts['tittle'] . '" class="btn-modern text-center"></a>
</div>';
}

add_shortcode( 'slider','slider_function' );