Tuesday, November 26, 2013

Add Class to Next and Previous links in Wordpress

Write below code in function.php file to add class on next prev links for pagination

<?php 
add_filter('next_posts_link_attributes', 'posts_next_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_prev_link_attributes');

function posts_next_link_attributes() {
return 'class="nav_next_class"';
}

function posts_prev_link_attributes() {
return 'class="nav_prev_class"';
}
?>

above function will add "nav_next_class" to next link and "nav_prev_class" to previous link.
:)