Forums

[resolved] Can't undo "title" value for links (7 posts)

  1. AndrewBanchich
    Member
    Posted 2 years ago #

    Here is my site. If you notice on the upper left there is a menu with a rollover effect. When you keep the cursor over the links the title pops up, which is the same as the link, which i think is redundant and unnecessary, so i'd like to make it not show any "title" value at all. Here is the code I use to display the menu links, but i don't know how to remove the title value. Can anyone help?

    <div class="pages">

    <? unset($pages); ?>
    </div>

  2. AndrewBanchich
    Member
    Posted 2 years ago #

    Sorry, here's the code:

    <div class="pages">
       <ul>
       <li<?php if ( is_front_page() ) echo ' class="current_page_item"'; ?>><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li>
    <?php $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
    $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
    $pages = str_replace('</a>','</span></a>', $pages);
    echo $pages; ?>
      </ul>
    <? unset($pages); ?>
     </div>
  3. iridiax
    Member
    Posted 2 years ago #

    If you don't have many pages and they don't change a lot, you could just skip wp_list_pages and code the links to your pages yourself. This way, you can customize or eliminate the title.

    Also try a forum search for this. I remember reading about someone developing a plugin to remove link titles from wp_list_pages links.

  4. AndrewBanchich
    Member
    Posted 2 years ago #

    I searched for a question about this but I couldn't find it, sorry.

    And I am a beginner at php so I wouldn't want to break anything.

  5. Mark / t31os
    Moderator
    Posted 2 years ago #

    Give this a shot...

    <div class="pages">
       <ul>
       <li<?php if ( is_front_page() ) echo ' class="current_page_item"'; ?>><a href="<?php echo get_option('home'); ?>/"><span>Home</span></a></li>
    <?php $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
    $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
    $pages = preg_replace('/title=\"([^>]+)\"/', '', $pages);
    $pages = str_replace('</a>','</span></a>', $pages);
    echo $pages; ?>
      </ul>
    <?php unset($pages); ?>
     </div>

    EDIT: Updated the code, used the previous preg_replace regex since it'll be more effective at replacing the titles properly...

    Some handy regex'ed preg_replace examples here.
    talkincode.com/using-the-e-modifier-in-php-preg_replace-400.html

  6. AndrewBanchich
    Member
    Posted 2 years ago #

    Worked perfectly! Thank you so much!

  7. Mark / t31os
    Moderator
    Posted 2 years ago #

    You're welcome... ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags