Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Problem next_posts_link() in P2 integration attempt


peterverkooijen
Participant

@peterverkooijen

OK, slightly modified to prevent the function from messing with dots (.) and return the result instead of echo:

function removedoubles($string){
$string = preg_replace("/([,?!])/"," 1",$string);
$parts = explode("/",$string);
$unique = array_unique($parts);
$unique = implode("/",$unique);
$unique = preg_replace("/s([,?!])/","1",$unique);
return $unique;
}

This applied to function next_posts and previous_posts in /wp_includes/link_template.php:

function next_posts( $max_page = 0, $echo = true ) {
$output = removedoubles(esc_url( get_next_posts_page_link( $max_page ) ) );

if ( $echo )
echo $output;
else
return $output;
}

This works. Changes in core files is not ideal of course, so I’ll probably have to copy a lot of code and turn it into a custom version in functions.php.

Or is there a cleaner way? Is it possible to put something in functions.php that “catches” any calls for function previous_posts() and redirects them to a function custom_previous_posts() in functions.php?

Skip to toolbar