WordPress.org

Support

Support » How-To and Troubleshooting » Dynamic links – assign ID/class

Dynamic links – assign ID/class

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

    TIA

Viewing 4 replies - 1 through 4 (of 4 total)
  • Seriously, no-one?

    djones101
    Member

    @djones101

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

    Doodlebee
    Member

    @doodlebee

    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?

    djones101
    Member

    @djones101

    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.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dynamic links – assign ID/class’ is closed to new replies.