php – how to get sentence values from wordpress shortcode parameter?


I’ve set up a shortcode that gets sentence value from parameter, but it only returns the first word of the sentence. I’ve assumed that the shortcode recognizes values after whitespaces, but when I use double quotes, it breaks the shortcode. is there any workaround on this? thanks in advance.

here is my code:

function summary_items( $atts , $content = null) {

    $defaults = shortcode_atts( array(
        'item' => '------',
    ), $atts );

    $output="<li>". esc_attr($defaults['item']) .'</li>';
    return $output;


add_shortcode( 'summary_items', 'summary_items' );

I use it like this:

[summary_items item=this is a test] //this outputs "this" only.
[summary_items item="this is a test"] // breaks the shortcode

jn_lance 2 years 2022-06-09T21:33:33-05:00 0 Answers 0 views 0

Leave an answer