Reputation: 93
I wonder how to add id attribute to links generated by previous_posts_link()
and next_posts_link()
functions. I found that I can add class with this code:
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
return 'class="styled-button"';
}
But how to to do with id
attribute ?
Upvotes: 2
Views: 341
Reputation: 12571
I believe you could simply use multiple filters to handle this:
add_filter('next_posts_link_attributes', 'set_next_id');
add_filter('previous_posts_link_attributes', 'set_previous_id');
function set_next_id() {
return 'id="next"';
}
function set_previous_id() {
return 'id="previous"';
}
Upvotes: 3