Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the following snippet to automatically break a too long post into multiple pages

function filter_more_with_nextpage( $content ){

    $content = str_replace( '<!--more-->', '<!--nextpage-->', $content );
    $content = preg_replace( '/<!--nextpage-->/i', '<!--more-->', $content, 1 );

    return $content;
}
add_filter( 'content_save_pre', 'filter_more_with_nextpage' );

works like a charm, but I'd like to add automatically a link <a> element before the page break to help directing users to the following page.

I don't wish to put the link in the post content manually (from wp backend) nor have it inserted automatically in the post content (I don't want it saved along the post itself). Rather, I'd wish to have it generated just before <!--nextpage--> tag breaks the current page.

share|improve this question
    
From above code, where's the problem with inserting that anchor/link tag? –  kaiser Jun 23 '13 at 12:06
    
the filter is for content_save_pre and will convert via regex the more tags after the first one, if I add more filtering to content_save_pre it will be saved inside the post which I don't want; I think I like most the Krzysiek idea, very simple :) –  nekojira Jun 23 '13 at 15:06

1 Answer 1

up vote 1 down vote accepted

If you use <!--nextpage--> tag, then you could use wp_link_pages function. Just put it in your single.php template.

share|improve this answer
    
thanks! this is simple and effective! silly me for not having thought of it :) –  nekojira Jun 23 '13 at 15:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.