From 1a47e9d8397d1d66f6a3320858b5269c22ea3071 Mon Sep 17 00:00:00 2001 From: rboren Date: Sat, 7 Aug 2004 18:12:54 +0000 Subject: [PATCH] Fix get_pagenum_link() to work with path info permalinks and permalinks without trailing slashes. Bug 0002040. git-svn-id: http://svn.automattic.com/wordpress/trunk@1514 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-functions-links.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index c9c11a6672..e14823d924 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -331,7 +331,13 @@ function get_pagenum_link($pagenum = 1){ // otherwise, it could be rewritten, OR just the default index ... } elseif( '' != get_settings('permalink_structure')) { $permalink = 1; - $qstr = preg_replace('|(.*)/[^/]*|', '$1/', $qstr).$page_modstring.$pagenum; + + // If it's not a path info permalink structure, trim the index. + if ( ! preg_match('#^/*' . get_settings('blogfilename') . '#', get_settings('permalink_structure'))) { + $qstr = preg_replace("#/*" . get_settings('blogfilename') . "/*#", '/', $qstr); + } + + $qstr = trailingslashit($qstr) . $page_modstring . $pagenum; } else { $qstr = get_settings('blogfilename') . $querystring_start.$page_querystring.$querystring_equal.$pagenum; }