Adding class to prev/next

I’ve been using the below code to add classes to get_next_post_link (in functions.php of my child theme)

add_filter('get_next_posts_link', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');

function posts_link_attributes() {
return 'class="x-btn x-btn-global"';
}

This was working until a recent theme update. Can you tell me how to add a class to these links now?

Hello There,

Thanks for posting in! Your code is incorrect. Please have it updated and use this:

add_filter('previous_posts_link_attributes', 'x_posts_link_attributes');
add_filter('next_posts_link_attributes', 'x_posts_link_attributes');

function x_posts_link_attributes() {
  return 'class="x-btn x-btn-global"';
}

We would loved to know if this has work for you. Thank you.

This update worked, thank you

You’re welcome!
Thanks for letting us know that it has worked for you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.