Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter heyitsjeremy

    (@heyitsjeremy)

    Thanks! Just what I needed. 🙂

    Sorry for the late response.

    Thread Starter heyitsjeremy

    (@heyitsjeremy)

    Ah ha! I got it. In case anyone else needs it:

    Add this to you template-functions-category.php file:

    function get_cat_nicename($cat_ID) {
    $cat_ID = (int) $cat_ID;
    $category = &get_category($cat_ID);
    return $category->category_nicename;
    }

    And then this to your template-functions-general.php file:

    function single_cat_nicename($prefix = '', $display = true ) {
    $cat = intval( get_query_var('cat') );
    if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
    $my_cat_name = get_cat_nicename($cat);
    if ( !empty($my_cat_name) ) {
    if ( $display )
    echo $prefix.strip_tags($my_cat_name);
    else
    return strip_tags($my_cat_name);
    }
    }
    }

    Then you can just call it via a template file:

    <?php /* If this is a category archive */ if (is_category()) { single_cat_nicename(); }?>

    Thread Starter heyitsjeremy

    (@heyitsjeremy)

    First of all, thank you so much for the help! However, when I place that in template-functions-general.php and then try to call it in my template, I get:

    Fatal error: Call to a member function get_queried_object() on a non-object in C:\www\blog\wp-includes\template-functions-general.php on line 709

    Any ideas? This is for WordPress 2.0.

Viewing 3 replies - 1 through 3 (of 3 total)