Need help getting category menu to format

14 replies
I have a theme which lists my pages in a horizontal menu, with drop down sub-menu items for the sub-pages. I wanted to add a menu item for categories, so I added the following code to my menu.php script ...

Code:
<?php 
wp_list_categories('sort_column=name&sort_order=asc&include=22,24,25&style=list&children=true&hierarchical=true&title_li=' . __('Memberships') . ' ''); 
?>
But, when the page was rendered, there was no margin between the menu item separator and the menu text, so I added spaces into the title so that the ('Memberships') part of the code became (' Memberships ')...

Code:
<?php 
wp_list_categories('sort_column=name&sort_order=asc&include=22,24,25&style=list&children=true&hierarchical=true&title_li=' . __(' Memberships ') . ' ''); 
?>
There was no change, as it appeared Wordpress had stripped the spaces out. So I did a little research, and added a div with float and margins ...

Code:
<div class="kwadded" style="float:left; margin-left: 10px; margin-right: 10px;">
<?php 
wp_list_categories('sort_column=name&sort_order=asc&include=22,24,25&style=list&children=true&hierarchical=true&title_li=' . __('Memberships') . ' ''); 
?>
</div>
I got the left margin spaced, but the right margin was again stripped out. So I played with it and found that by adding a space and a character to the ('Memberships') part of the code, making it ('Memberships |'), I could simulate a right margin. (I used the pipe symbol trying to be unobtrusive.) The code is ...

Code:
<div class="kwadded" style="float:left; margin-left: 10px;">
<?php 
wp_list_categories('sort_column=name&sort_order=asc&include=22,24,25&style=list&children=true&hierarchical=true&title_li=' . __('Memberships  |') . ' ''); 
?>
</div>
You can see the results at Consultant Supply Room (Note that the categories aren't listed unless you are logged in. This question is only about getting a margin to appear in this added menu item.)

Can someone advise me of a way to get the menu item to include the right margin? Or, how to find out what is causing the problem? I don't know if it is being stripped out by the theme or Wordpress.

Thanks in advance,
Kirk
#category #format #menu
  • Profile picture of the author Tim Brownlaw
    Hi Kirk, these types of problems always grab my attention.

    Can you tell me what theme this is based upon?
    That would help me try it out and have a fiddle with it.
    Which is another way of saying, I need to see more of what the menu.php file looks like.

    Or someone's going to come along and have an "Ah Ha" moment for you but I'm happy to help out if that doesn't happen.

    Cheers
    Tim
    {{ DiscussionBoard.errors[1247041].message }}
  • Profile picture of the author Kirk Ward
    Hi Tim,

    I am using the iNews theme from iThemes (http://ithemes.com)

    I have a redistribution license to the theme if you want to take a look.

    And the aha's just aren't coming. I've piddled all evening.

    Thanks,
    Kirk
    Signature
    "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

    Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
    {{ DiscussionBoard.errors[1247057].message }}
    • Profile picture of the author Tim Brownlaw
      Hey Kirk - what time is it over there?

      Well whatever you are happy to do, I'm ok with.
      You've probably become a bit weary eyed staring at this...

      Just PM me the details - I'm around for a wee bit and I'd love to be able to have you go....WoooHooooo!

      If you are into that kind of thing and then Get Some Sleep!

      Cheers
      Tim
      {{ DiscussionBoard.errors[1247250].message }}
      • Profile picture of the author Kirk Ward
        Thanks for the offer Tim, I just sent you a PM, and a copy of the theme through another channel. I am getting bleary eyed as you probably guessed. It am 1:40 in the AM here. I'm off to nighty night.

        Cheers, and all that sort of stuff.
        Signature
        "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

        Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
        {{ DiscussionBoard.errors[1247302].message }}
        • Profile picture of the author Tim Brownlaw
          Ok Kirk,

          I tried that snippet of code they gave you on the Forum with the UL's etc.. and it works.

          So to get you going - use that instead of what you were trying.

          It's manual but if it works - use it.

          Code:
          <li class="page_item"><a href="http://consultantsupplyroom.com/membership/">Membership</a>
          <ul>
          <li><a href=http://"http://consultantsupplyroom....ership-login/">Please Log In</a></li>
          </ul>
          </li>
          Cheers
          Tim
          {{ DiscussionBoard.errors[1247426].message }}
          • Profile picture of the author Tim Brownlaw
            Give me a nudge - yeah I'm awake!

            Umm yes, as you stated in your email , you got that bit working.

            To get the categories showing in the menu is going to take a little effort.

            I'm still looking.

            Cheers
            Tim
            {{ DiscussionBoard.errors[1247475].message }}
            • Profile picture of the author Tim Brownlaw
              Kirk,
              I've had a god bash at it. It's interesting.

              The problem is the classes being generated.
              Listing of categories is a little different to pages. Having said that I've been playing with a new function to list the categories and make them look like pages for the menu only.

              But as I'm getting a bit blurry eyed I'll have to give it a rest for now but I'll be back on it.

              I'm trying to learn the in's and outs of Wordpress to make the propeller on my cap spin faster ( reference to being a nurd ) so it's why I've jumped in to help out.
              Nothing better than a real life problem to solve.

              We'll get there. There are a few ways to go and I'm just trying to find the one of least resistance by just changing the themes functions.

              Cheers
              Tim
              {{ DiscussionBoard.errors[1248290].message }}
  • Profile picture of the author Kirk Ward
    Thanks Tim,

    If you are able to do that, it might be a popular plugin. I see a lot of folks asking similar questions every now and then.

    Will be waiting with baited breath ...

    Kirk
    Signature
    "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

    Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
    {{ DiscussionBoard.errors[1249378].message }}
    • Profile picture of the author Tim Brownlaw
      Kirk,

      Check your email mate.
      It's got some "Stuff" in it that should do the trick for the time being.


      Cheers
      Tim
      {{ DiscussionBoard.errors[1251457].message }}
  • Profile picture of the author Kirk Ward
    Great Job Tim ...

    It looks beautiful ...

    Any way to control which categories can be listed there? Say only certain ones in the list?

    I see the exclude=> action ... can the include => be used to limit the inclusions to the certain ones?

    However, that is a "picky" thing. It looks good enough I can live with it the way it is.

    Thanks 407 gazillion times over.

    Kirk
    Signature
    "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

    Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
    {{ DiscussionBoard.errors[1251526].message }}
    • Profile picture of the author Tim Brownlaw
      Hi Kirk,

      I'm glad it's working.

      I thought you might want to have the "Exclude" ability

      I'll give it a go at putting that in. I was just making sure what I got working so far was what you were after.

      Only a few more days at my Day JOB and then I'm a free agent. So I'll have a bit more time.

      Cheers
      Tim
      {{ DiscussionBoard.errors[1252611].message }}
  • Profile picture of the author Kirk Ward
    Thanks again Tim,

    It's all beautiful. 'Exclude =>' worked out just fine. Took a minute or five to get my head in the right place. Now trying to figure out how to get the "No Categories" (which was edited to read "Please Log In") message to appear when no categories are allowed to show because they are protected.

    Will play and think.
    Kirk
    Signature
    "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

    Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
    {{ DiscussionBoard.errors[1253343].message }}
    • Profile picture of the author Tim Brownlaw
      Hi Kirk,

      I've seen you've been having a good play with the "new" bit.

      I'm learning up on making it a plug-in. Seems like fun...

      One thing I have noticed though and that is - the words fall out of the menu when the category name get's too long.

      A thought I had was to maybe use the category description field and have it display in the menu. That way you can keep your longer Categories showing up on the page and the abbreviated versions in the menu.

      That was something I found in my digging around. Or the simpler way is to just have shorter category names.

      I see now that's not an issue for you, but it's something to take into consideration.

      It's all fun and thanks for letting me help you out. I appreciate it.

      I've now started in on the Plugin writing side of things and this little exercise was just the ticket...

      Cheers
      Tim
      {{ DiscussionBoard.errors[1254508].message }}
  • Profile picture of the author Kirk Ward
    Thanks Tim,

    I had the problem with long category names before and now that this is working, I just went in and edited the names so that they would fit. It is not related to the function ... but maybe your idea of using the description field might provide a solution.

    Thanks again, seventy or eighty times over.

    Kirk
    Signature
    "We are not here to sell a parcel of boilers and vats, but the potentiality of growing rich beyond the dreams of avarice."

    Dr. Samuel Johnson (Presiding at the sale of Thrales brewery, London, 1781)
    {{ DiscussionBoard.errors[1254528].message }}

Trending Topics