WordPress.org

Ready to get started?Download WordPress

Forums

how to do this in PHP, bullets issue... (13 posts)

  1. mixmastermichael
    Member
    Posted 2 years ago #

    Hi there,

    I have a site that has the following code to display a bullet using • before each nav item in the wordpress menu. Is there a way I can set it up so that it only applies to everything BUT the first item??

    <?php wp_nav_menu( array('menu' => 'Footer Menu', 'before' => ' • ', 'after' => ' ','container_id' => 'links_foot') ); ?>

    Any help would be appreciated.

  2. esmi
    Forum Moderator
    Posted 2 years ago #

  3. mixmastermichael
    Member
    Posted 2 years ago #

    thanks for the reply but I know css very well, your post is a little condescending... even if I were to use it for a bulleted list there is no way to have li:first-child{ list-type: none;} to get it to work which is why I am trying this php route....

    any ideas?

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    1. You did not indicate your level of CSS proficiency, therefore we have to assume the lowest common denominator.

    2. This is a pure CSS question and really has nothing specifically to do with WordPress.

    3. li:first-child{ list-type: none;} works perfectly well (on a non-floated list)

  5. mixmastermichael
    Member
    Posted 2 years ago #

    If you could provide an example of what you mean that would be great. The trouble is that the li needs to be floated so that it's a horizontal list, not vertical.

    I was trying to use the dynamically created menu with a wp array to do this which is why I thought to post it here. Just need to have it so that the bullet does not show up on the first list item though.

    <?php wp_nav_menu( array('menu' => 'Footer Menu', 'before' => ' • ', 'after' => ' ','container_id' => 'links_foot') ); ?>

    thanks for the reply!

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Bullets won't be displayed on a floated list element. That's just how most browsers handle this situation. Try adding a bullet graphic as a background-image.

  7. mixmastermichael
    Member
    Posted 2 years ago #

    hmm that's not really working.... anyone know of a way I can amend the php code so that the • only appears on everything BUT the first li using this code?
    <?php wp_nav_menu( array('menu' => 'Footer Menu', 'before' => ' • ', 'after' => ' ','container_id' => 'links_foot') ); ?>

  8. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 2 years ago #

    I would use a bullet graphic as a background image with appropriate padding - as Esmi suggested - that would be simple to implement in CSS & change rule for the first li

  9. mixmastermichael
    Member
    Posted 2 years ago #

    see I've tried numerous times, and the the thing is that the first li can't have it as list type: none it can't really be done... I've tried a few different options, done a ton of google searching for an example, but can't see a correct example of how it would work.

  10. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 2 years ago #

    you don't need to set just the first list item's list type to none - set them all to none and specify a bullet image as the background for the list items. This should give you as much control as you need

  11. mixmastermichael
    Member
    Posted 2 years ago #

    but I think it still has the bullet image as the background even for the first one, which isn't what I need.

    Thanks for the reply

  12. timDesain
    Member
    Posted 2 years ago #

    add span to your nav_menu
    <?php wp_nav_menu( array('menu' => 'Footer Menu', 'before' => ' <span>•</span> ', 'after' => ' ','container_id' => 'links_foot') ); ?>

    then add style

    #links_foot ul{
    padding: 10px 0;
    margin: 0;
    list-style: none;
    }
    #links_foot li:first-child span{
    display: none;
    }
    #links_foot li{
    display: inline;
    }

    you are good in css, right?

    I know css very well

    http://www.w3schools.com/css/ and http://www.w3.org/Style/CSS/learning will give you more
    :)

  13. mixmastermichael
    Member
    Posted 2 years ago #

    Awesome. Thanks so much for checking it out... never even thought about putting that bull; in a span. Very clever.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.