Changeset 444848
- Timestamp:
- 09/28/2011 03:52:51 PM (14 years ago)
- Location:
- count-shortcode/trunk
- Files:
-
- 2 edited
-
count_shortcode.php (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
count-shortcode/trunk/count_shortcode.php
r409314 r444848 4 4 Plugin URI: http:// 5 5 Description: Shortcode to count number of posts that match a given set of criteria; provides link to query to display list of matching posts 6 Version: 1.16 Version: 2.0 7 7 Author: The Federal Communications Commission 8 8 Author URI: http://fcc.gov/developers … … 46 46 add_shortcode( 'count', 'fcc_count_shortcode' ); 47 47 48 /** 49 * List all terms in a given taxonomy, or across all taxonomies 50 * 51 * Usage: [list-counts taxonomy="tags"] 52 * Usage: [list-counts] 53 * Usage: [list-counts hide_empty="true"] 54 * 55 */ 56 function fcc_list_taxonomy_shortcodes( $atts, $content = null ) { 57 58 $defaults = array( 'taxonomy' => implode( ',', get_taxonomies() ), 'hide_empty' => false ); 59 60 $atts = shortcode_atts( $defaults, $atts ); 61 62 $taxs = explode( ',', $atts['taxonomy'] ); 63 64 $output = '<div class="counts-list">'; 65 66 foreach ( $taxs as $tax ) { 67 68 $tax_obj = get_taxonomy( $tax ); 69 70 if ( !$tax_obj ) 71 return false; 72 73 if ( !$tax_obj->query_var || !$tax_obj->public ) 74 continue; 75 76 $terms = get_terms( $tax_obj->name ); 77 if ( sizeof( $terms ) == 0) 78 continue; 79 80 $output .= '<div class="taxonomy ' . $tax .'">'; 81 $output .= '<strong>' . $tax_obj->labels->name . '</strong><ul>'; 82 83 $output .= wp_list_categories( array( 84 'taxonomy' => $tax, 85 'show_count' => true, 86 'echo' => false, 87 'title_li' => false, 88 'hide_empty' => $atts['hide_empty'], 89 ) ); 90 91 $output .= "</div>"; 92 93 } 94 95 $output .= "</div>"; 96 97 return $output; 98 99 } 100 101 add_shortcode( 'list-counts', 'fcc_list_taxonomy_shortcodes' ); 102 48 103 ?> -
count-shortcode/trunk/readme.txt
r409732 r444848 1 1 === Plugin Name === 2 Contributors: fcc , benbalter2 Contributors: fcc 3 3 Donate link: 4 4 Tags: counting, statistics, shortcode, data, queries, links … … 29 29 You can also use the post_type argument to specify a post type (page, post, car, etc.) 30 30 31 **List Usage** 32 33 You can count all terms within a taxonomy, e.g., [list-counts taxonomy="tags"] or across all taxonomies [list-counts]. 34 31 35 == Installation == 32 36 … … 35 39 == Changelog == 36 40 41 = 2.0 = 42 * Added ability to display counts of all terms in a taxonomy, or across all taxonomies 43 37 44 = 1.0 = 38 45 * Initial Release
Note: See TracChangeset
for help on using the changeset viewer.