Added Classes on Post Navigation in WordPress


Sponsored Links




If you are WordPress fanatics, there is some reason why we need to added extra classes on some WordPress standard code. Example we need adding extra classes and other attributes on previous_post_link() and next_post_link().

Adding Classes In WordPress - Anri Sugihara

Adding Classes In WordPress - Anri Sugihara

To do this WP Tricks, we need to create some function on our functions.php, the function we need is to added the code with add_filter method. Follow this tricks

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"'; 
}

What actually this snippet does is adding the html you return in the function to the anchor.

<a href="http://wptricks.net&quot; THIS CODE WILL BE ADDED HERE>Standard Code</a> 

So, on this tutorial you can add ID, classes and other attributes an anchor can have. By default it will only have the href attribute. I hope How To Added Classes on Post Navigation in WordPress is Working on you, if you have another method, please let’s me know

Thanks for WPCanyon to share this Tricks

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


2 Responses to Added Classes on Post Navigation in WordPress

  1. Pingback: How to Add a Search Form on Navigation Menu Automatically « Rockinfrnz Archive

  2. Pingback: How to Add a Search Form on Navigation Menu Automatically | WebFree.ro

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>