How do I remove the link element from the current page in a wp_list_pages menu?

WP makes a list of links, and helpfully applies a current_page class, but I’m concerned with the accessibility issues of a link to the page you’re on.

Normally I’d swap the <a href etc with a <span, How would you approach that with WordPress?

Read More

(apart from manually creating the list of pages!)

Related posts

Leave a Reply

2 comments

  1. Rewriting the entire walker class is a big pain… much more work than is justified for the result. But you can use a bit of javascript to remove the link. If you’re including jquery, something like this should work:

    jquery(document).ready(function() {
        jquery('.current_page_item a').removeAttr( 'href' );
        });