Post body:
[paragraph value="1"]text text text[/paragraph]
[paragraph value="2"]moretext moretext moretext[/paragraph]
Desired result:
You are reading paragraph 1: text text text
You are reading paragraph 2: moretext moretext moretext
Can that be achieve using the above structure cause I couldn’t figure out how to do it using the examples at: https://codex.wordpress.org/Shortcode_API
Can you have enclosing shortcodes and values in them or are these 2 different shortcode types?
Yes. That result can be achieved by single shortcode function. Here is your code-
function paragraph_shortcode( $atts, $content = null ) {
$pull_atts = shortcode_atts( array(
'value' => 0
), $atts );
return 'You are reading paragraph ' . wp_kses_post( $pull_atts[ 'value' ] ) . ': ' . do_shortcode($content);
}
add_shortcode( 'paragraph', 'paragraph_shortcode' );
It’ll work as you expected. Just input your data as you described-
[paragraph value="1"]text text text[/paragraph]
[paragraph value="2"]moretext moretext moretext[/paragraph]
An d you’ll get your desired output.