Arguments of wp_link_pages()
Maybe this will work for you:
$args = array(
'before' => '<ul><li>' . __( 'Pages:' ),
'after' => '</li></ul>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'separator' => '</li><li>',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => '%',
'echo' => 1
);
wp_link_pages( $args );
The output is for example:
<ul>
<li>Pages:</li>
<li> 1 </li>
<li> <a href="http://example.com/hello-world/2/">2</a></li>
<li> <a href="http://example.com/hello-world/3/">3</a></li>
<li> <a href="http://example.com/hello-world/4/">4</a></li>
</ul>
You can also use 'echo' => 0
to read it into a variable, where you can modify it further via regular expressions.
Filters for wp_link_pages()
Another way is to use the filters wp_link_pages
and / or wp_link_pages_link
.
Here is an example:
function custom_wp_link_pages_link( $link )
{
return '<li>' . $link . '</li>';
}
add_filter( 'wp_link_pages_link', 'custom_wp_link_pages_link' );
that will give you the following HTML output:
<ul>
<li> 1 </li>
<li> <a href="http://example.com/hello-world/2/">2</a></li>
<li> <a href="http://example.com/hello-world/3/">3</a></li>
<li> <a href="http://example.com/hello-world/4/">4</a></li>
</ul>
for
wp_link_pages( array( 'before' => '<ul>', 'after' => '</ul>' ) );