How to insert shortcode with more parameters and multiline into WordPress page? Backslash used to work as a line separator:
[my_shorcode parameter_1=10 \
parameter_2=20 \
parameter_3="test"]
But it doesn't work in the latest WordPress version. I want to use more lines for better readability of the code.
Thanks for @Arvind K. for advice
This is not good idea since it breaks normal post editing behavior. Rather you should try to keep shortcodes "short
I've been solving this problem by the way
1. I have used shortcode this way [my-shortcode id="1"]
2. I have created post type My Shortcodes
3. The id
for step 1. is the My Shortcodes post id
4. In ACF (Custom fields) I have created fields for My Shortcodes
(Field - is shortcode param)
5. Then you could use your My Shortcodes post for getting fields.
add_shortcode( 'my-shortcode', function ( $atts, $content ) {
$custom_shortcode_id = $atts['id'];
$parameter_1 = get_field( 'parameter_1', $custom_shortcode_id );
$parameter_2 = get_field( 'parameter_2', $custom_shortcode_id );
return "Your shortcode content $parameter_1, $parameter_2";
} );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With