id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc,focuses 11871,"$pagenow is wrong in frontend processing (always set to ""index.php"")",codestyling,,"The global var ''$pagenow'' will be evaluated at all versions using the '''vars.php''' ''else'' path (non admin pages). But this is the wrong place. It's only possible to set the correct processed page (template file name) at the '''template-loader.php''' after evaluation of correct template file! In my opinion there should be a function inside the ''template-loader.php'' like: {{{ function redefine_pagenow($template) { global $pagenow; if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $template, $self_matches) ) $pagenow = strtolower($self_matches[1]); else $pagenow = 'index.php'; } }}} and the ''if/else'' cascades should use the function for redefine the correct template file been processed currently as frontend view (example excerpt): {{{ ... } else if ( is_single() && $template = get_single_template() ) { redefine_pagenow($template); include($template); return; } else if ( is_page() && $template = get_page_template() ) { redefine_pagenow($template); include($template); return; } else if ( is_category() && $template = get_category_template()) { redefine_pagenow($template); include($template); return; ... }}} This will permit theme/template designer to detect using the correct ''$pagenow'' var what template is been currently processed instead of always ''index.php'' This problem is also related to older versions of WordPress. ",defect (bug),closed,high,,Template,2.9.1,critical,invalid,template pagenow defect,,