2

i have the following shortcode

function cta_button($atts , $content = null) {
   extract(shortcode_atts(array(
      'cta_url' => '',
      'cta_buttentext' => '',
   ), $atts));
return '<div class="ctabox"><div class="ctacontent">' . $content . '</div><a href="http://'. $cta_url . '" class="ctabutton">' . $cta_buttentext . '</a><br style="clear: both;"></div>';
}
add_shortcode( 'cta', 'cta_button' );

If I use the shortcode in the editor with

[cta cta_url=http://www.domain.com cta_buttentext=This is just a test]Text[/cta]

the text "This is just a test" is to short/wrong. On the front end, it shows only "This". The rest of the string is "emtpy". "is just a test" is cut.

Can you help me? And sory for my english :(

bg janw

1 Answer 1

1

You should put quotes around the attribute value, since spaces are what WordPress uses when it parses for new attributes:

[cta cta_url="http://www.domain.com" cta_buttentext="This is just a test"]Text[/cta]
Sign up to request clarification or add additional context in comments.

Comments

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.