August 2017
Beginner
412 pages
10h 30m
English
Let's create a simple shortcode that will make it possible to use our widget's output inside any given post or page. This is going to be a double-tag shortcode with one additional attribute, which we'll use to indicate whether the output should be formatted using our custom CSS or WordPress' native styling.
Let's start by creating a new function at the bottom of our kk_tag_cloud_widget.php file, and then, we'll go through each individual line:
function kk_tag_cloud_handler($atts, $content=null) { extract(shortcode_atts(array( 'use_css' => '1', 'taxonomy' => 'post_tag' ), $atts)); $tax = 'post_tag'; if(taxonomy_exists($taxonomy)) $tax = $taxonomy; $result = ''; if ('0' != $use_css) { $result .= '<div class="kk_widget_tag_cloud"><div ...Read now
Unlock full access