treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress menu classnames

  • Hi,

    I can't find any way to manually edit the classes applied to my wp_list_pages(); function. I would really like to have classes applied to the a-tag as well as the li-tag.

    Anyone know of a useful plugin or something?

    I'm afraid there's no standard way of doing it.
  • I'm new to the whole hacking wordpress so if this isn't the Wordpress Approved Method, I'd like to know the answer as well.

    But it seems to me you can basically just add stuff like this:


    //Get the stuff from wp_list_pages
    $myvar = wp_list_pages('echo=0&title_li=');

    // Find the li to add a class to
    $var1 = '<li class=\"';
    $var2 = '<li class=\"myclass ';

    //Find the a to add a class to
    $var3 = '<a';
    $var4 = '<a class=\"myclassa\" ';

    // Replace var1 with var 2, and var 3 with var 4.
    $myvar = str_replace($var1, $var2, $myvar);
    $myvar = str_replace($var3, $var4, $myvar);

    //print out the resulting stuff
    print \"myvar = \" . $myvar;