WordPress.org

Ready to get started?Download WordPress

Forums

Menu shouldn't show draft pages (5 posts)

  1. sjoannef
    Member
    Posted 1 year ago #

    Being able to schedule a page or post to be published is great. But, I can't find any way to also have the new page added to a particular menu as soon as it goes live. So now I have this great automated way to set up a future page, but I still have to remember to log in and add the menu. Do you know of any plugin or setting that will help with this issue?

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Have you noticed the "Automatically add new top-level pages" checkbox at the top of your custom menu in Appearance -> Menus?

  3. BramNL
    Member
    Posted 1 year ago #

    I think what he asks is that if a menu item links to a page that has the status 'draft', the menu item itself should be hidden for the public also.

    Is that possible?

    [edit]
    Also, that checkbox you mention, works only for top-level menu items. It is actually a kinda dangerous checkbox if you tend to forget to set the parent page for a new page. Especially because it doesn't remove the menu item after you have "fixed" the forgotten parent page setting.

  4. ktulucom
    Member
    Posted 1 year ago #

    I'd like to do this as well, but plugins like Revisionary aren't working with my theme :/

  5. sinds78
    Member
    Posted 1 year ago #

    I used this as a solution for hiding draft pages. You can hide the (draft page) menu items with the li.draft class.

    add_filter('nav_menu_css_class' , 'nav_menu_add_post_status_class' , 10 , 2);
    function nav_menu_add_post_status_class($classes, $item){
    	$post_status = get_post_status($item->object_id);
    	$classes[] = $post_status;
    	return $classes;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic