• Hello,
    Can anyone help me with this or give me some advice?

    I have a loop that is listing all the names of a custom post type in a certain category linking to their specific page (creating a menu). I’m trying to figure out a way, in the loop to set a class of “current” to one of the names when you’re on that page.

    Something like this, but I want it to add it to one item in the loop for the current page, whatever that may be.
    if ( is_single( "post_name" ) ) { echo ' class="current_page_item" '; }

    I can probably just create a menu of the posts, but I wanted this to be dynamic so when a post is created it automatically gets added to the menu.

    My loops is working fine to list all the post names, but I just want that class “current” to get added to the one you’re on.

    Any help is appreciated.

  • The topic ‘Setting current page class in a loop of post names’ is closed to new replies.