WordPress.org

Support

Support » How-To and Troubleshooting » how to do this in PHP, bullets issue…

how to do this in PHP, bullets issue…

  • 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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • esmi

    @esmi

    Forum Moderator

    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?

    esmi

    @esmi

    Forum Moderator

    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)

    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!

    esmi

    @esmi

    Forum Moderator

    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.

    mixmastermichael

    @mixmastermichael

    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’) ); ?>

    Moderator cubecolour

    @numeeja

    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

    mixmastermichael

    @mixmastermichael

    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.

    Moderator cubecolour

    @numeeja

    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

    mixmastermichael

    @mixmastermichael

    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

    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
    🙂

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

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘how to do this in PHP, bullets issue…’ is closed to new replies.
Skip to toolbar