Skip to content

Instantly share code, notes, and snippets.

@braginteractive
Created July 9, 2015 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save braginteractive/4dbc754476f3c8ad4db8 to your computer and use it in GitHub Desktop.
Save braginteractive/4dbc754476f3c8ad4db8 to your computer and use it in GitHub Desktop.
Add class to posts navigation links for WordPress
/**
* Filter to add class to next/previous navigation links
*/
function posts_link_attributes() {
return 'class="mdlwp-nav__button"';
}
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function post_link_attributes($output) {
$class = 'class="mdlwp-nav__button"';
return str_replace('<a href=', '<a '.$class.' href=', $output);
}
add_filter('next_post_link', 'post_link_attributes');
add_filter('previous_post_link', 'post_link_attributes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment