Index: wp-blog-header.php =================================================================== --- wp-blog-header.php (revision 2526) +++ wp-blog-header.php (working copy) @@ -85,7 +85,7 @@ } } -$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup'); +$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence', 'debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup','custom_key','custom_val'); $wpvarstoreset = apply_filters('query_vars', $wpvarstoreset); Index: wp-includes/classes.php =================================================================== --- wp-includes/classes.php (revision 2526) +++ wp-includes/classes.php (working copy) @@ -21,6 +21,8 @@ var $is_time = false; var $is_author = false; var $is_category = false; + var $is_customkey = false; + var $is_customval = false; var $is_search = false; var $is_feed = false; var $is_trackback = false; @@ -40,6 +42,8 @@ $this->is_time = false; $this->is_author = false; $this->is_category = false; + $this->is_customkey = false; + $this->is_customval = false; $this->is_search = false; $this->is_feed = false; $this->is_trackback = false; @@ -170,6 +174,14 @@ if ( ($this->is_date || $this->is_author || $this->is_category)) { $this->is_archive = true; } + + if ('' != $qv['custom_key']) { + $this->is_customkey = true; + } + + if ('' != $qv['custom_val']) { + $this->is_customval = true; + } } if ('' != $qv['feed']) { @@ -416,6 +428,39 @@ $whichcat .= ")"; } + // custom_key/custom_val stuff + + if ('' != $q['custom_key'] || '' != $q['custom_val']) { + // can only add join statement once, so custom_key and custom_val are combined in one conditional. + if (stristr($q['custom_key'],'/')) { + $q['custom_key'] = explode('/',$q['custom_key']); + if ($q['custom_key'][count($q['custom_key'])-1]) { + $q['custom_key'] = $q['custom_key'][count($q['custom_key'])-1]; // no trailing slash + } else { + $q['custom_key'] = $q['custom_key'][count($q['custom_key'])-2]; // there was a trailling slash + } + } + if (stristr($q['custom_val'],'/')) { + $q['custom_val'] = explode('/',$q['custom_val']); + if ($q['custom_val'][count($q['custom_val'])-1]) { + $q['custom_val'] = $q['custom_val'][count($q['custom_val'])-1]; // no trailing slash + } else { + $q['custom_val'] = $q['custom_val'][count($q['custom_val'])-2]; // there was a trailling slash + } + } + $q['custom_key'] = sanitize_title($q['custom_key']); + $q['custom_val'] = sanitize_title($q['custom_val']); + $tables .= ", $wpdb->postmeta"; + $join .= " LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) "; + if ('' != $q['custom_key']) { + $where .= " AND ($wpdb->postmeta.meta_key = '" . $q['custom_key'] . "')"; + } + if ('' != $q['custom_val']) { + $where .= " AND ($wpdb->postmeta.meta_value = '" . $q['custom_val'] . "')"; + } + } + + // Author/user stuff if ((empty($q['author'])) || ($q['author'] == '0')) { @@ -1290,4 +1335,4 @@ $wp_rewrite = new WP_Rewrite(); } -?> \ No newline at end of file +?>