今天Sophia特别告诉我工作达人下方的连结都点不进去,这奇怪的问题ㄚ琪一直搞不懂是server升级后的问题,还是Wordpress升级后的问题造成。
ㄚ琪就把问题假设是固定网址的问题,发现好像不是。
再把问题假设成是Apache 的mod_rewrite没有开,去检查也有开?
继续找了一个早上,发现How To Fix the 3.1 Custom Permalinks Bug这一篇提到,这是3.1版的问题?
好奇怪以前怎没有注意到这个问题?好吧,先把它当死马医吧。
ㄚ琪在自制布景主题里的functions.php中放入了文中建议的程式码:
// repairs the custom permalink bug with WordPress 3.1+ // works with or w/out custom permalinks enabled add_action('init', 'wcs_hotfix_31_redirect_canonical', -1); remove_filter('template_redirect', 'redirect_canonical'); function wcs_hotfix_31_redirect_canonical() { // hotfix version: 0.97 // developed by Luke America with valuable assistance by Jonas Nordstrom // source code release 2011-03-23 // updated 2011-04-05 (added fixes to pagination for searches, categories, & tags) // updated 2011-04-08 (added support for multisites that use subdirectories) // updated 2011-04-09 (added hotfix bypass to retain XML-RPC Support) // updated 2011-04-11 (added fixes for RSS feeds for categories & tags) global $wp_version; // does NOT assume bug will be fixed by next version release if ((!is_admin()) && ($wp_version >= 3.1)) { // extract current URI $uri = untrailingslashit($_SERVER['REQUEST_URI']); // bypass hotfix to retain XML-RPC Support $pos = strpos($uri, 'xmlrpc.php'); if ($pos >= 1) {return;} // process hotfix for custom permalink CAT lookup $pos = strpos($uri, 'category/'); if ($pos >= 1) { // prep fix for CAT rss feeds $feed = ''; if (strpos($uri, 'feed')) { $feed = '&feed=rss2'; $uri = substr($uri, 0, strlen($uri) - 5); } // continue CAT hotfix $pos = strrpos($uri, '/'); $len = strlen($uri); $cat_slug = substr($uri, $pos + 1, $len - $pos - 1); $cat_id_object = get_category_by_slug($cat_slug); $cat_id = $cat_id_object->term_id; $url = site_url('?cat=' . $cat_id . $feed); header("Location: $url"); exit; } // process hotfix for custom permalink TAG lookup $pos = strpos($uri, 'tag/'); if ($pos >= 1) { // prep fix for TAG rss feeds $feed = ''; if (strpos($uri, 'feed')) { $feed = '&feed=rss2'; $uri = substr($uri, 0, strlen($uri) - 5); } // continue TAG hotfix $pos = strrpos($uri, '/'); $len = strlen($uri); $tag_slug = substr($uri, $pos + 1, $len - $pos - 1); $url = site_url('?tag=' . $tag_slug . $feed); header("Location: $url"); exit; } if (empty($_SERVER['QUERY_STRING'])) { // handle true 404's, normal processing, etc redirect_canonical(); } else { // fix pagination for categories, tags, and searches $page_query = wcs_hotfix_31_get_page($uri); if ($page_query != '') { $url = site_url() . $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; $url .= '&' . $page_query; header("Location: $url"); exit; } // handle default queries (not needed) //$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; } } /********************************************************************** Copyright c 2011 Gizmo Digital Fusion (http://wpCodeSnippets.info) you can redistribute and/or modify this code under the terms of the GNU GPL v2: http://www.gnu.org/licenses/gpl-2.0.html **********************************************************************/ }
function wcs_hotfix_31_get_page($uri) { // init $page = ''; $pos = strpos($uri, 'page/'); // convert to page query if ($pos >= 1) { $page = substr($uri, $pos + 5); $page = 'paged=' . intval($page); } // exit return $page; }
OK!测试成功,收工,等等,网址那里怎会变成非固定网址啊?还是觉得有点怪怪的,希望下一版的Wordpress有解。