Add classes to anchor elements with wp_list_pages

On a recent WordPress theme I am building, I am using the template tag wp_list_pages() to generate my site navigation. I need to be able to add classes to the anchor tags that this function generates and unfortunately, it does not provide this capability in its API.

The WordPress forum has come to the rescue however and there is a way around this, heres how:

Open up the functions.php file within your theme folder and add the following line to your theme’s functions.php template file, and it will add a class attribute of “tag” to each link generated by wp_list_pages()

Contact Me