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 Answers 2

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' );
Sign up to request clarification or add additional context in comments.

Comments

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' );

1 Comment

I see what is going on here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.