Support » Developing with WordPress » Is there a better way to get the category title than the slug?

  • Is there a better way to do this so I am not having to strip a dash from the slug?

    if (get_query_var('category_name')) {
            $currentCategory = ucwords(str_replace('-', ' ', get_query_var('category_name')));
        }
    
        if (get_query_var('tag')) {
            $currentTag = ucwords(str_replace('-', ' ', get_query_var('tag')));
        }

    <h1><?php echo ucwords(str_replace('-', ' ', $currentCategory)); ?></h1>

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.