Does a shortcode with a single attribute have to use an array?

I want to build a shortcode that takes a single attribute.

Everything online is telling me to make it using an array:

// Add Shortcode
function bg_comparison_points_shortcode( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
‘custom_field’ => ”,
),
$atts,
‘comparison_points’
);
return bg_calculate_points($custom_field);
}
add_shortcode( ‘comparison_points’, ‘bg_comparison_points_shortcode’ );

But in my mind something like this would be much simpler

// Add Shortcode
function bg_comparison_points_shortcode( $custom_field ) {
return bg_calculate_points($custom_field);
}
add_shortcode( ‘comparison_points’, ‘bg_comparison_points_shortcode’ );

Is there a problem doing this simpler version?

Read more here:: Does a shortcode with a single attribute have to use an array?

Leave a Reply

Your email address will not be published. Required fields are marked *