Dynamic links - assign ID/class (5 posts)

  1. Lee Rickler
    Posted 7 years ago #

    Currently I am using this to determine the title of a PAGE and assign an ID - if it's something do this, if not, do something else:

    <h3<?php if (is_page('PAGE NAME'))
                    echo " id=\"current\"";
                    }?>><a href="PAGE NAME">PAGE NAME</a></h3>

    This works fine for fixed links.

    My question is:
    How do I do the same for dynamic links to POSTS using this:

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>


  2. Lee Rickler
    Posted 7 years ago #

    Seriously, no-one?

  3. djones101
    Posted 7 years ago #

    i am having similar issues.... its seems to be severely lacking this ability.

  4. Doodlebee
    Posted 7 years ago #

    Are you trying to set a current page class to your links? WordPress already does this when you use wp_list_pages and wp_list_categories. It already knows what page you're on, and will assign a "current-page-item" or "current-cat-item" class to the link associated with it.

    Is that what you're trying to do?

  5. djones101
    Posted 7 years ago #

    I hate to hi-jack a thread but here is the link to my thread explaining exactly what I was trying to do... LINK

    You can reply here that would be awesome. or on mine. or on both. I have static and dynamic links on my page in an <ul> I would like to be able to have 5 static links on every page and then have the ability to dynamically bring in 1 to 5 other links.


Topic Closed

This topic has been closed to new replies.

About this Topic