[Resolved] Issue with custom menu item

Home Forums Support [Resolved] Issue with custom menu item

Home Forums Support Issue with custom menu item

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #228076
    stardrive

    Hi Tom,

    Please, custom menu item is not displaying in your secondary menu above the main menu.

    I used this code:

    function your_custom_menu_item ( $items, $args ) {
        if (is_single() ) {
            $items .= '<li>Show whatever</li>';
        }
        return $items;
    }
    add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );

    In this case, Show whatever is my custom menu item.

    Please, kindly assist

    Regards,

    Stardrive

    #228185
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I think using a plugin would be better in this case: https://en-ca.wordpress.org/plugins/if-menu/

    #228237
    stardrive

    Hi Tom,

    Thanks for your response.

    I replaced if (is_single() ) {
    with

    if(is_user_logged_in() && $args->theme_location == ‘secondary’)

    and the code worked.

    Sorry I should have informed you much earlier

    Thank you.

    #228344
    Tom
    Lead Developer
    Lead Developer

    No worries, glad you got it working 🙂

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