WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to use the wp_list_pages as a navigation bar, but I don't want the links to be followed. This is the simple version of the code I'm using <?php wp_list_pages('hierarchical=1&title_li=&depth=1'); ?> but I have no idea how to add the "nofollow" to the links.

share|improve this question

use wordpress build in funcion for that "wp_rel_nofollow" with a hook to wp_list_pages.

paste this code in your theme's functions.php file and you are set.

function add_no_follow($output){
  return wp_rel_nofollow($output);
add_filter('wp_list_pages', 'add_no_follow');

hope this helps.

share|improve this answer
I think this will nofollow all wp_list_pages links on my site. I'm using this code for different purposes (to list different groups of pages) and I don't want all of them no-followed, just the links in my nav-bar. – user2716 Jan 25 '11 at 12:00
@Zmey: You can disable echo for wp_list_pages(), give the output to wp_rel_nofollow(), and echo the result of that. – Jan Fabry Jan 25 '11 at 12:12
Of course, thanks a lot! – user2716 Jan 25 '11 at 12:20
@Zmey - If you've found a solution with the information provided, please be sure to mark this as the correct answer. – t31os Jan 26 '11 at 14:06

paste this code in your theme's functions.php file.

function add_nofollow($text) {
    return str_replace('<a href=', '<a rel="nofollow" href=',  $text);    

add_filter('wp_list_pages', 'add_nofollow');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.