WordPress.org

Ready to get started?Download WordPress

Forums

Remove alt text on navigation links? (5 posts)

  1. tombc1234
    Member
    Posted 4 years ago #

    Hi,

    I'd like to know whether it's possible to remove the alt text that shows up when I hover my mouse across a navigation link in the header?

    When I look at header.php, I get:

    <?php wp_list_pages('title_li=&depth=1'); ?>

    Can anyone tell me how to edit the file that generates the page links so I can go into it and remove any 'alt' or 'title' instances that show up when the links are genereated?

    Thanks, Tom

  2. tombc1234
    Member
    Posted 4 years ago #

    Okay made a little inroad into this..

    I found out the classes.php is what handles the output of wp_list_pages, and this is what it looks like (i hope):

    $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . esc_attr(apply_filters('the_title', $page->post_title)) . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';

    Now, I've tried removing the 'title' instances, but that screws up the links. It gets rid of the alt tag, sure, but when clicked on gives me a 404.

    Which part of the code do I need to modify to remove the title="" and/or alt="" classes?

    Thanks

  3. tombc1234
    Member
    Posted 4 years ago #

    Just to clarify further, this is what I'm trying to do. Let's say I've got an ordinary link being rendered with HTML:

    <a href="#" class="link" title="#">

    I'm trying to remove the title="" bit from it, so that when I hover my mouse over a link, it doesn't display the little yellow box. But it's not presented as it is above, since it's generated through PHP which I know nothing about!

    Sorry to triple post, not for means of bumping merely developing the info so I can find a solution as quickly as possible, if there is one : )

  4. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    title="' . esc_attr(apply_filters('the_title', $page->post_title)) . '"

    if you remove exactly this snippet from the code you posted, you should be ok.

    however, editing core files is not considered 'good practice' as you need to repaet it with every update.

    also:
    http://wordpress.org/extend/plugins/remove-title-attributes/
    and

    http://bavotasan.com/tutorials/remove-the-title-attribute-from-wordpress-category-and-page-lists/

  5. tombc1234
    Member
    Posted 4 years ago #

    Thank you so much! Very helpful and informative post.

    I downloaded the plugin, which worked perfectly, as opposed to changing code manually, and then did some research and found a similar one for image title attributes: http://wordpress.org/extend/plugins/img-title-removal/ when I was asked to "get rid of the annoying little yellow boxes" from every image on the website (+200 photos..) saved me hours of mind numbing work!

Topic Closed

This topic has been closed to new replies.

About this Topic