ThemeShaper Forums » Thematic

How to add <em></em> inside <a> tags of wp_page_menu?

(2 posts)
  • Started 5 years ago by fltseng
  • Latest reply from fltseng
  • This topic is resolved
  1. fltseng
    Member

    Hey all,

    For the menu bar in thematic, I'd like to use the "Single Image Replacement" method as outlined in this tutorial:

    http://www.tyssendesign.com.au/articles/css/single-image-replacement-rollovers-with-suckerfish-dropdowns/

    where the list structure is as following:

    <ul class="nav IR">
      <li class="link1">
        <a href="#"><em></em>Link 1</a>
      </li>
      <li class="link2">
        <a href="#"><em></em>Link 2</a>
      </li>
      <li class="link3">
        <a href="#"><em></em>Link 3</a>
      </li>
    </ul>

    wp_page_menu does everything BUT add the < em></em > between the a tags.

    I've tried code that I found in this topic
    http://forums.themeshaper.com/topic/div-id-vs-class

    //changing 'class' to 'id'
    function change_menu($menu) {
    	$menu = str_replace('<div class="', '<div id="', $menu);
    	return $menu;
    }
    add_filter('wp_page_menu', 'change_menu');

    which seems to work perfectly for that, but not for anything else than that. This is what I tried:

    function change_menu($menu) {
    	$menu = str_replace('</a>', '<em></em></a>', $menu);
    	return $menu;
    }
    add_filter('wp_page_menu', 'change_menu');

    but to no avail.

    Any leader on how to do this would be super-awesome... I've been trying to fix this for hours now and am getting quite desparate :(

    Cheers,
    Fei

    Posted 5 years ago #
  2. fltseng
    Member

    Man, it's always always always that I find the answer right after I've posted on a forum after hours of searching.

    For some reason, the code above decided to start working fine, for no apparent reason. I also found another method which is way more wp-native:

    function change_menu($args)
    {
        $args = array(
    		'sort_column' => 'menu_order',
    		'menu_class' => 'menu',
    		'echo' => true,
    		'link_before' => '<em></em>'
    	);
        return $args;
    }
    add_filter('wp_page_menu_args', 'change_menu');

    I'm only beginning to understand how this theme and WP really works... it's a cool adventure for sure, but not when you're on a deadline!! :)

    Posted 5 years ago #

RSS feed for this topic

Reply

You must log in to post.