Skip to content

Instantly share code, notes, and snippets.

@dantetesta
Last active February 28, 2023 11:53
Show Gist options
  • Save dantetesta/cc5ea5c9a00e874a57c07c17e5c8a70b to your computer and use it in GitHub Desktop.
Save dantetesta/cc5ea5c9a00e874a57c07c17e5c8a70b to your computer and use it in GitHub Desktop.
/* ADICIONE ESSE TRECHO NO FUNCTIONS.PHP DO SEU TEMA */
/* SHORTCODE = [clouds tax="category"] */
function tagclouds_by_dabte_testa($atts) {
$atts = shortcode_atts( array(
'tax' => '',
), $atts );
$args = array(
'taxonomy' => $atts['tax'],
'orderby' => 'name',
'order' => 'ASC',
'show_count' => 1,
'hierarchical' => 1,
'title_li' => '',
'hide_empty' => 0
);
?>
<style>
ul.tagcloud {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 0;
margin: 0;
gap:10px;
}
ul.tagcloud li {
padding: 4px 12px;
margin:5px;
background-color: #C9EB55;
list-style: none;
border-radius: 100px;
}
ul.tagcloud li a {
color: #000000;
}
</style>
<?php
$categories = get_categories($args);
$output = '<ul class="tagcloud">';
foreach ($categories as $category) {
if($category->name!='Uncategorized'){
$output .= '<li><a href="'.get_category_link($category->term_id).'">'.$category->name.'</a></li>';
}
}
$output .= '</ul>';
return $output;
}
add_shortcode('clouds', 'tagclouds_by_dabte_testa');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment