﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc
10907	get_queried_object does not always return a category	dimitryz	dd32	"I've noticed that retrieving a category with {{{WP_Query::get_queried_object()}}} does not always work. When the query_var 'cat' is not set and 'category_name' is, nothing is returned. Shouldn't {{{get_queried_object()}}} also look in 'category_name' and, if present, retrieve the category using {{{get_category_by_path()}}}?

Here is a solution that seems appropriate:

{{{
function get_queried_object() {
...
if ($this->is_category) {
	$cat = $this->get('cat');
	if ($cat) {
		$category = &get_category($cat);
	} else {
		$cat = $this->get('category_name');
		$category = &get_category_by_path($cat);
	}
	if ( is_wp_error( $category ) )
		return NULL;
	$this->queried_object = &$category;
	$this->queried_object_id = (int) $category->term_id;
}
}}}"	defect (bug)	closed	normal		Query	2.8.4	normal	worksforme	reporter-feedback	
