• Good Evening,

    Hopefully an easy one for the php inclined, I think it’s just a syntax matter.

    I am using the following code for my global navigation (outside the loop):
    <ul id="globalnav"><?php echo get_links(3, '<li>', '</li>', ' + ', TRUE, 'id', FALSE, FALSE, 6, FALSE); ?> </ul>*

    I wish to add an individual class to the <li> tags using either the link_name or link_id (i.e. <li class="link_name">but I’m not sure how to call up this information in this context.

    The desired outcome is that I can use the cascade to highlight the current section of the site being used without needing to alter the globalnav code for each section.

    *Admittedly some of the other parameters in get_links may be different a I’m altering code that I have used for another group of links.

    Thanks xxx

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter spiritedpam

    (@spiritedpam)

    Don’t want to bother you all but surely someone knows how to do this, I’m sure it can be done, I just don’t know the way to write it.

    I’m not a php guru, but wouldn’t it be better if you used:
    <div class=what_ever>
    and put the <li> inside that?
    Or am I misunderstanding?

    Thread Starter spiritedpam

    (@spiritedpam)

    Not really I’m afraid. I need each link to have a different class – hence basing it on their name or id.

    <?php echo get_links('<li class="link_name">'); ?>

    I want something like this ^. Within get_links, link_name is defined as $name but li class=”$name” shows up an error.

    I’m sure I just need to know how to format it correctly. It’s just difficult for me to work out because we are already within double and single quotes and escaping the single quote to put in the variable doesn’t seem to work because it disrupts the function.

    In this scenario; <?php echo get_links('<li class=" how do I put in a variable?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding individual classes to get_links (syntax query)’ is closed to new replies.