• Resolved Chantal Coolsma

    (@chantalc)


    I use the line in my header file:

    <?php wp_page_menu('show_home=<img src="/wp-content/themes/mytheme/images/logo-small.png" alt="Home">'); ?>

    This shows the page menu with a logo image as the home button. Works okay for one thing. When I hover the mouse over the image the alt pops up with:

    <img src="/wp-content/themes/mytheme/images/logo-small.png" alt="Home">

    You should expect that the alt-tag (in this case “Home”) would be used. Any clues to work around this?

Viewing 1 replies (of 1 total)
  • Thread Starter Chantal Coolsma

    (@chantalc)

    Already found a solution. Replaced:

    <?php wp_page_menu('show_home=<img src="/wp-content/themes/mytheme/images/logo-small.png">'); ?>

    with:

    <?php
    // Replace the correct title tag for image in wp_page_menu
    function correct_title($titletag) {
    return preg_replace('/"<img src=&quot;\/wp-content\/themes\/mytheme\/images\/logo-small.png&quot;>"/', '\'Home\'', $titletag, 1);
    }
    add_filter('wp_page_menu','correct_title');
    
    wp_page_menu('show_home=<img src="/wp-content/themes/mytheme/images/logo-small.png">');
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘[wp_page_menu] How do I solve this?’ is closed to new replies.