How can I add a different classes for “next” and “previous” links with wp_link_pages?

I am using wp_link_pages function and I want to add different div classes for “next” and “previous” links (using ‘next_or_number’ => ‘next’ arg).

I was trying to do it like this:

Read More
<?php
        $args = array(
        'before'           => '<div class="next">',
        'after'            => '</div>',
        'next_or_number'   => 'next',
    ); 

    wp_link_pages( $args ); ?>

Than I have a similar classes for both next and previous link.
But I need a “next” class for next link and “previous” class for previous link.

I’ve also tried something like this:

<?php $args = array(

'before'           => '<div class="page-link-next-prev">',
'after'            => '</div>',
'next_or_number'   => 'next',
'nextpagelink'     => __('<div class="next">Continue Reading</div>'),
'previouspagelink' => __('<div class="prev">Go Back</div>') ?>

<?php wp_link_pages( $args ); ?>

But than I have div class=”next” inside link and it wraps only the text.

Do you have any ideas?

Related posts