Adding custom ANCHOR classes to WP_link_pages Previous Next Buttons

Posted in: Newsmag
Post count: 15

Hi,

I’m trying to add custom classes to the wp_link_pages’ ANCHORS so I can have more flexibility with the styling.

Right now when the wp_link_pages is called the theme outputs the pagination as follows:

<div class="page-nav page-nav-post td-pb-padding-side clearfix">
Previous
Next
</div>

All the docs I’ve found in relation to wp_link_pages add classes to the div element. However I need to add custom classes to the A element such as:

<div class="page-nav page-nav-post td-pb-padding-side clearfix">
Previous
Next
</div>

Can that be done?

  • This topic was modified 10 years by louist.
  • This topic was modified 10 years by louist.
  • This topic was modified 10 years by louist.
  • This topic was modified 10 years by louist.
Post count: 15

I couldn’t get the links to show up properly on the first post so here’s the post again:

Hi,

I’m trying to add custom classes to the wp_link_pages’ ANCHORS so I can have more flexibility with the styling.

Right now when the wp_link_pages is called the theme outputs the pagination as follows:

<div class="page-nav page-nav-post td-pb-padding-side clearfix"><a href="http://localhost/wordpress/demo-5-reasons-you-need-the-x-theme/">Previous</a><a href="http://localhost/wordpress/demo-5-reasons-you-need-the-x-theme/3/">Next</a></div>

All the docs I’ve found in relation to wp_link_pages add classes to the div element. However I need to add custom classes to the A element or previous and next such as:

<div class="page-nav page-nav-post td-pb-padding-side clearfix"><a class="newclass1" href="http://localhost/wordpress/demo-5-reasons-you-need-the-x-theme/">Previous</a><a class="newclass2" href="http://localhost/wordpress/demo-5-reasons-you-need-the-x-theme/3/">Next</a></div>

Can that be done?

  • This reply was modified 10 years by louist.
  • This reply was modified 10 years by louist.
  • This reply was modified 10 years by louist.
Post count: 6535

Hi

The pagination links are generated by WordPress so to add a new css class for a elements you need to edit the pagination function from WordPress. This is a complex task and I can’t provide a solution now. If you need this and you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you as we can’t offer customization services at the moment.

Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newsmag’ is closed to new topics and replies.