• I have a menu item that I have to turn on and off. “Scholarship” on our main menu top bar. It is scholarship season and when the deadline is over I need to turn it off. But I do not want to delete it. I just want it to disappear from the menu till I need to activate it this time next year.

    I have tried several different things and cannot figure out where I can do this or even if I can.

    Bob

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • The menu item links to a page. Set the visibility to “Private”. The menu item would then only be visible to you after logging in – not publicly. The page too.

    Thread Starter davet354tfd

    (@davet354tfd)

    I have tried that. It still leaves the “Scholarship” tab in the menu and when you select it you get a 404 error.

    I want to be able to have that “Scholarship” to disappear when we are not offering it, but be able to enable it when we are.

    Bob

    Ok, that probably depends on your theme. With many themes, the visibility of the target page is checked by menu items. I just had a look at your theme and wrote the following individual PHP code for it:

    function custom_hide_menu_entry( $item_output, $css_class ) {
        if( $css_class->object_id > 0 && 'publish' !== get_post_status( $css_class->object_id ) ) {
            return '';
        }
        return $item_output;
    }
    add_filter( 'walker_nav_menu_start_el', 'custom_hide_menu_entry', 10, 2 );

    You would have to insert this in a child theme or via a code snippet plugin. Remember to make a backup of your project beforehand, just to be on the safe side.

    Alternatively, you could also hide the menu item using CSS:

    #menu-item-1031 { display: none; }

    Insert under Appearance > Customiser > Additional CSS. Next year you just have to remember to show it again by removing this line.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Menu Buttons’ is closed to new replies.