[Resolved] Custom Post Type – Current Page

Home Forums Support [Resolved] Custom Post Type – Current Page

Home Forums Support Custom Post Type – Current Page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #143469
    antware

    Hi Tom

    Am using GP with a child theme for a new project I’m working on.

    Have created several Custom Post Types and when I go to a Single Custom Post Type, the News button (I assigned my News page to list my Blog entries) on the menu displays as the current page. So in other words the Theme is seeing my Custom Post Type as a regular Post.

    I don’t want the News button to be “highlighted” for Custom Post Types when I’m browsing a Custom Post Type but definitely for Normal Post Types, when I’m viewing a normal post.

    Any idea as to how I could do this?

    #143481
    bdbrown

    Hi Antony. I don’t know that there is a “one size fits all” fix but here are a couple of related posts that might help get you started:

    https://generatepress.com/forums/topic/highlight-in-menu-nav/

    https://generatepress.com/forums/topic/menu-item-forum-thinks-it-is-a-child-of-item-blog/

    https://generatepress.com/forums/topic/menu-highlight-problem/

    #143493
    Tom
    Lead Developer
    Lead Developer

    This is kind of annoying WordPress issue.

    This function works: https://gist.github.com/generatepress/f5e4f6d1795cf6bb4c6a

    You would just have to replace this line:

    case 'forum':

    with

    case 'yourposttype':

    #143611
    antware

    Thanks Thomas, that resolved it.

    Thanks too to bdbrown, for your contribution.

    #143742
    Tom
    Lead Developer
    Lead Developer

    Glad we could help 🙂

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.