Treehouse: Grow your CSS skills. Land your dream job.

WordPress menu classnames

  • # December 7, 2009 at 3:03 pm


    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.

    # December 7, 2009 at 4:22 pm

    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:

    <div class="bbcode_code">
      <div class="bbcode_code_head">
      <div class="bbcode_code_body" style="white-space:pre">
        //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;
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.