Friday, June 10, 2022
HomeWordPress Developmentphp - learn how to get sentence values from wordpress shortcode parameter?

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


I’ve arrange a shortcode that will get sentence worth from parameter, but it surely solely returns the primary phrase of the sentence. I’ve assumed that the shortcode acknowledges values after whitespaces, however after I use double quotes, it breaks the shortcode. is there any workaround on this? thanks upfront.

right here is my code:

operate summary_items( $atts , $content material = null) {

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

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

}

add_shortcode( 'summary_items', 'summary_items' );

I exploit it like this:

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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments