<?php
function get_all_category_ids() {
- global $wpdb;
-
if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
$cat_ids = get_terms('category', 'fields=ids&get=all');
wp_cache_add('all_category_ids', $cat_ids, 'category');
}
function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
- global $wpdb;
$category_path = rawurlencode(urldecode($category_path));
$category_path = str_replace('%2F', '/', $category_path);
$category_path = str_replace('%20', ' ', $category_path);
// Get the ID of a category from its name
function get_cat_ID($cat_name='General') {
- global $wpdb;
-
$cat = get_term_by('name', $cat_name, 'category');
if ($cat)
return $cat->term_id;
// Tags
function &get_tags($args = '') {
- global $wpdb, $category_links;
-
- $key = md5( serialize( $args ) );
- if ( $cache = wp_cache_get( 'get_tags', 'category' ) )
- if ( isset( $cache[ $key ] ) )
- return apply_filters('get_tags', $cache[$key], $args);
-
-
$tags = get_terms('post_tag', $args);
if ( empty($tags) )
return array();
- $cache[ $key ] = $tags;
- wp_cache_set( 'get_tags', $cache, 'category' );
-
$tags = apply_filters('get_tags', $tags, $args);
return $tags;
}