Skip to content

Instantly share code, notes, and snippets.

@davidchc
Created March 22, 2019 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidchc/c409fa51ed268694a7a51a4ffea12d29 to your computer and use it in GitHub Desktop.
Save davidchc/c409fa51ed268694a7a51a4ffea12d29 to your computer and use it in GitHub Desktop.
Exemplo de criação de shortcode com código existente
<?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