wp_list_pages isnt showing title attribute

I'm using wordpress on my site and for some reason the wp_list_pages() isn't showing a title attribute?

I'd love to add it for the SEO purposes.

Any help?

My current code is

wp_list_pages('depth=1&title_li=&exclude=9');

Answers


wp_list_pages() not supposed to have a title attribute by default. You can always write your own functions if the given functions don't fit your needs.

<?php 
function mytheme_list_pages($param) {
  $pages = get_pages($param); 
  foreach ( $pages as $page ) {
    $li  = '<li><a href="' . get_page_link( $page->ID ) . '" title="';
    $li .= esc_attr($page->post_title);
    $li .= '">';
    $li .= $page->post_title;
    $li .= '</a></li>';
    echo $li;
  }
}
?>

Place this in your themes function.php and use it instead of wp_list_pages(). If you are using a standard wordpress theme I recommend creating a child theme for this, since theme updates will remove your changes in the future. Feel free to add any ids and classes as you need them. It gets a little more complicated when you add css classes like current_page_item for the currently visible page to the generated HTML markup.


Need Your Help

Capybara+rspec:Reset_Password routing error

ruby-on-rails rspec capybara email-spec

So I am trying to test the simple feature of forgot password.I am newbie, so excuse me if its a silly question.

Render field errors in for loop with Flask-WTF

python validation flask wtforms flask-wtforms

I would like to iterate over form's fields in a template and display fields with errors like this: