Using sprintf in shortcode
-
Hi,
I have a page-template that displays a form via a shortcode, I use this to display the form:
echo do_shortcode( '[my-form]' );
I want a text input field in backend so user can insert shortcode attributes (so user can rename form labels). My field is called ‘attributes’.
I use this to display the shortcode in page-template, including inserted attributes.
$content = sprintf('[my-form %s]', esc_attr($instance['attributes']) ); if ( !empty( $instance['attributes'] ) ) { echo do_shortcode( $content ); }
Code works, but can I use a sprintf in this case?
Because it has nothing to do with a ‘normal’ text string.Guido
Viewing 14 replies - 1 through 14 (of 14 total)
Viewing 14 replies - 1 through 14 (of 14 total)
- The topic ‘Using sprintf in shortcode’ is closed to new replies.