How to add CSS Class to previous_post_link or get previous/next post link URL

You can use the more native function that is “below” the previous_/next_post_link();:

# get_adjacent_post( $in_same_cat = false, $excluded_categories="", $previous = true )
$next_post_obj  = get_adjacent_post( '"https://wordpress.stackexchange.com/questions/17218/,"', false );
$next_post_ID   = isset( $next_post_obj->ID ) ? $next_post_obj->ID : '';
$next_post_link     = get_permalink( $next_post_ID );
$next_post_title="»"; // equals "»"
?>
<a href="https://wordpress.stackexchange.com/questions/17218/<?php echo $next_post_link; ?>" rel="next" class="pagination pagination-link pagination-next">
    <?php echo $next_post_title; ?>
</a>

Leave a Comment