If you’re using wp_link_pages()
with 'next_or_number'
set to 'number'
(or not set at all, it’s the default), which you presumably are, then you can use the wp_link_pages_link
filter.
wp_link_pages_link
lets you filter the HTML for each individual page link that’s output. The 2nd argument, $i
, gives you the page number. You can use this to conditionally output HTML before or after the link depending on the current page number.
For example, if I wanted to output a <br>
tag after the second link, I would do this:
function wpse_296614_page_link( $link, $i ) {
if ( $i === 2 ) {
$link = $link . '<br>';
}
return $link;
}
add_filter( 'wp_link_pages_link', 'wpse_296614_page_link', 10, 2 );
Related Posts:
- Automatically add after X number of paragraphs
- Customizing wp_link_pages
- Add a Class to Current Page WP_LINK_PAGES
- Can I add a ‘show all pages’ link to wp link pages?
- Add Unique Classes to Next and Previous in WP_LINK_PAGES
- Add query string to wp_link_pages links
- Adding wp_link_pages to a theme that seems to lack?
- Make Current/Active Page Number a Link (WP_LINK_PAGES)
- How to ignore wp_link_pages function?
- alternative to wp_link_pages() that only shows link to last page
- Remove Spaces From WP_LINK_PAGES
- How do I change page numbers to words?
- wp_link_pages appearing after post content and not at bottom of page
- Paged posts – how to use numbers and next/previous links?
- Appending content with broken in 4.4
- Shortcode to insert
- How to get only the URL of nextpage (without tag)
- Single Page View for Paginated Posts
- How to get a page url by a page id?
- the_content and wp_link_pages
- Check if on last page of paginated post using wp_link_pages
- and previews
- How to style current page number (wp_link_pages)?
- How to ignore or disable nextpage tag?
- Allow Users to Choose Pagination or Next/Previous (Combine)
- Programmatically inserting page breaks
- as a shortcode within the loop?
- wp_link_page – wrap current page element
- wp_link_pages output appears twice
- WordPress post/page pagination (page links) to go back to the first section
- Getting two wp_link_pages output
- wp_link_pages: display current page number only if has multiple page breaks?
- Append a to every post to force additional page link (and static content)
- Previous & Next on Index Page broken
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- Display only the current page number and another numbered page in pagination
- Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?
- Insert pagination links – wp_link_pages() – before filters on posts
- How to deal with equal & similar arguments for a function?
- How do I detect which page I’m on within a paginated post?
- WordPress wp_link_pages show only next/prev link
- Can I use images as anchor tags with
- add_filter(‘the_content’, ‘…’) stops pagination from working
- Show all parts in multipage post
- Only nextpagelink on wp_link_pages
- Is it possible to skip certain specified pages when using < prev and next > links?
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Post Pagination Customization (wp_link_pages) Editing Navigation
- Sort order of next/prev sibling page
- How to use the filter?
- Loading post with Ajax
- Please help me with tag and php code [closed]
- WordPress /page/2 not working
- Adding range to wp_link_pages()
- Limiting number of visible links displayed with wp_link_pages
- PHP code to use on next & previouspage links
- Post Pagination Modifications (wp_link_pages)
- How to customize wp_link_pages()?
- Make wp_link_pages() suitable for Twitter Bootstrap markup
- Custom wp_link_pages for paginated posts | Next page randomly
- “paged” in WP_Query returns 0 posts
- How to create a page /1 using ?
- Get a link to paged() part?
- Widget background images missing on second blog excerpt page
- Give wp link pages it’s own template
- query to use to link to taxonomy single page
- Automatically adding a link to the next page link before ” tag in posts?
- WP_LINK_PAGES Generating Unnecessary Tag
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Unable to Change “Pages:” Before WP_LINK_PAGES
- Adding an Unlinked Space in a Custom Function
- Next Page & Previous Page links – skipping a single page – how?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- Single article separated into multiple pages makes Facebook Like button detect as completely separated articles
- Help to modify wp_link_pages()
- How is the Page Splitting implemented in the theme?
- Removing menus from users other than the administrator
- Using within a shortcode
- wp_link_pages shortcode for ‘nextpagelink’
- Linking images in WordPress Paginated Post
- using globals from wp_link_pages function
- Override wp_link_pages pagebreak with filter
- How to make the show as a button?
- Display Both next previous and number in single page [duplicate]
- Publish and go to page [duplicate]
- Multipage Post URL correction
- Need some Tweak my nextpage Function
- inserting every 200 characters automatically
- Test for if you’re on 1st page of paginated post (with nextpage quicktag)
- Add wp-link-pages to post
- Get next and previous page of paginated post
- How do I paginate posts page with $wpdb?
- Trying to display next and previous set of posts on separate page (not parent page)
- How can I display wp_link_pages before a shortcode, if it is used, or display after content?
- Modifying Page-Links format
- Making a Killer wp_link_pages
- Single post pagination
- Next Page Link shows same posts on custom template
- Use add_rewrite_rule to change subpage url
- Can’t link to pages from Home Front Page now. Get 404