Answer the question
In order to leave comments, you need to log in
Why is the shortcode displayed twice on the page?
function rating_function($atts) {
extract(shortcode_atts(array(
'rating' => 5,
'type' => 'rating',
'number' => 0
), $atts));
return wp_star_rating(array('rating' => $rating, 'type' => $type, 'number' => $number));
}
add_shortcode('rating', 'rating_function');
Answer the question
In order to leave comments, you need to log in
Do not use the extract() function (works similar to array_merge ). It is considered bad style and its use is deprecated, even for core Wordpress. This is not safe, often creates a lot of conflicts, and also overwrites some data. It is likely that this is the problem. Better this way:
$args = shortcode_atts(
array(
'rating' => 5,
'type' => 'rating',
'number' => 0,
),
$atts
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question