WordPress.org

Support

Support » How-To and Troubleshooting » wp_list_pages highlight current page in single.php template

wp_list_pages highlight current page in single.php template

  • Im using wp_list_pages throughout my site in a sidebar to list the child pages of the current page. The current page item feature works fine when i click one of these child pages but when i click into a post, in the single.php template, it dosen’t highlight what page the post is under, the current page item class disappears. Does anyone know a way around this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • That’s because posts aren’t in the page hierarchy. How would it know/ how are you telling it what page should be the parent of the post?

    Well, if i change my reading settings, post page to one of the child pages i need highlighted, e.g blog, when i click into a single post in the blog page, it adds the current_page_item class inside the single.php template, but it only works for that one page, so, if it can do it that way, one can only hope that there is another method that targets all the pages rather than the one that i manually select

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_list_pages highlight current page in single.php template’ is closed to new replies.
Skip to toolbar