Problem next_posts_link() in P2 integration attempt
-
I’ve integrated the P2 theme into my custom theme. I have an annoying problem with the next_posts_link() and previous_posts_links() tags. They produce links like these:
mysite.com/blogname/blogname/page/2/
That would work fine if the blogname wasn’t put in there twice. P2 uses its own (?) function posts_nav_link, instead of next_posts_link, but the result is the same.
The links are formed by a function get_pagenum_link() in wp-includes/link-template.php. The magic happens here somewhere:
...
if ( $pagenum > 1 ) {
$result = add_query_arg( 'paged', $pagenum, $base . $request );
} else {
$result = $base . $request;
}
} else {
$qs_regex = '|?.*?$|';
preg_match( $qs_regex, $request, $qs_match );
if ( !empty( $qs_match[0] ) ) {
$query_string = $qs_match[0];
$request = preg_replace( $qs_regex, '', $request );
} else {
$query_string = '';
}
$request = preg_replace( '|page/d+/?$|', '', $request);
$request = preg_replace( '|^index.php|', '', $request);
$request = ltrim($request, '/');
$base = trailingslashit( get_bloginfo( 'url' ) );
if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
$base .= 'index.php/';
if ( $pagenum > 1 ) {
$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
}
$result = $base . $request . $query_string;
}
$result = apply_filters('get_pagenum_link', $result);
...I’ve tried editing the preg_replace regex mess, with some partial results, but I have no clue what’s going on exactly in this function.
Can anyone spot what is going on here? Why does the blogname show up twice? What can I remove to remove one?
- The topic ‘Problem next_posts_link() in P2 integration attempt’ is closed to new replies.