Created
March 22, 2019 18:37
-
-
Save davidchc/c409fa51ed268694a7a51a4ffea12d29 to your computer and use it in GitHub Desktop.
Exemplo de criação de shortcode com código existente
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode("star_rating", "fn_star_ratings"); | |
function fn_star_ratings($atts, $content=null){ | |
$data = shortcode_atts(["id" => 0], $atts); | |
return kk_star_ratings($data["id"]); | |
} | |
add_shortcode("star_rating_get", "fn_star_rating_get"); | |
function fn_star_rating_get($atts, $content){ | |
$data = shortcode_atts(["total" => 10], $atts); | |
$posts = kk_star_ratings_get($data["total"]); | |
$response = ""; | |
foreach($posts as $p) { | |
$response .= "<li>".$p->ratings."</li>"; | |
} | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment