WordPress.org

Forums

No Home link option in wp_nav_menu & no current-menu-item for custom post types (10 posts)

  1. Paul Wright
    Member
    Posted 5 years ago #

    Hello,

    I'm using the new wp_nav_menu for my site and I was wondering why there isn't an option in the Appearance->Menus area of the backend for adding 'Home' to the menu.

    I'm using a home.php template file, so there isn't technically a 'Page' for me to drag into the menu.

    The obvious workaround is to create a "Custom Link" and point it to a url of / which I have done. The problem though, is the wp_nav_menu doesn't add the "current-menu-item" class that it does to actual pages.

    Paul

  2. Boyevul
    Member
    Posted 5 years ago #

    If you're talking about the base URL of your blog (www.example.com) or (www.example.com/blog) or whatever ->

    Function Reference/get bloginfo

    url
    home (deprecated)
    siteurl (deprecated)
    the Blog address (URI) is the URL for your blog's web site address and is set in Administration → Settings → General. This data is retrieved from the home record in the wp_options table.

  3. Yes, that would be useful. I've added a feature request in Trac for that.

    http://core.trac.wordpress.org/ticket/13213

  4. Paul Wright
    Member
    Posted 5 years ago #

    Appreciated, thanks

  5. unozip
    Member
    Posted 4 years ago #

    I had a similar problem and found a band-aid for the missing "current-menu-item" (or "current_page_item") class.

    It requires adding a class to the custom link and then pulling a unique (auto-generated) body class from the corresponding page. Using both these classes it's possible to style the link in a way that only shows on the appropriate page and fakes the current/active status.

    In my case I added a "currentpageitem" class to the custom link, and pulled a "type-location" class from the body on the corresponding page. The CSS looks like this:

    #access li.current_page_item a,
    body.type-location #access li.currentpageitem a {
    color: #a00e2b;
    }

  6. bencharity
    Member
    Posted 4 years ago #

    In case you are still looking, I found the answers here:

    http://wpfirstaid.com/tag/wp_nav_menu/

    He shows how to add links before the menu (eg home) and then links after (eg rss or contact). All done with a snip of code in your theme's functions file.

  7. andreigusan
    Member
    Posted 4 years ago #

    Or just make a custom link and add "index.php" in the URL field and "Home" in the Label field :)

  8. unozip
    Member
    Posted 4 years ago #

    Part of my reason for taking the long way around was to be able to add current_page_item classes to the links for styling. I haven't found a way to do that using the built in Menu feature.

  9. markzero
    Member
    Posted 4 years ago #

    Or just make a custom link and add "index.php" in the URL field and "Home" in the Label field :)

    I search for this issue, came to this and just would like to add that I used what andreigusan said, but this is VERY strange: Chrome is not showing anchor of the first (home) custom item ?? Actually it generates double custom list item, one with and one WITHOUT anchor. If anyone could try this, and report the possible Chrome issue

  10. Rev. Voodoo
    Volunteer Moderator
    Posted 4 years ago #

    Here's the solution I found for the current_menu_item and CPTs. Wait for WP 3.1. 3.1 allows for use of the CPT has_archive feature. Once I activated the archives, and used them rather than making custom page templates for CPTs, everything worked great. (that covers part of the issue here)

Topic Closed

This topic has been closed to new replies.

About this Topic