Tagged: ,

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1411076

    Hi @ismael

    could you please check your snippet from here

    /**
    * hide draft pages from the menu
    */
    function avf_wp_nav_menu_objects_mod($items, $args) {
     foreach ($items as $i => $obj) {
         if (!is_user_logged_in () && 'draft' == get_post_status ($obj->object_id)) {
             unset ($items[$i]);
         }
     }
     return $items;
    }
    add_filter ('wp_nav_menu_objects', 'avf_wp_nav_menu_objects_mod', 10, 2);

    if it works still with the latest ENFOLD?

    I tried it and a page, that I have set to “draft” is still visible in the submenu.
    Also when I put a page from the main menu to “draft”, it remains also visible in the main menu.

    Could you please tell me, if your snippet mentioned above from 2022 is
    a) still valid for latest ENFOLD?
    b) works for draft pages/post in submenu AND in main menu?

    Thank you.

    #1411550

    Hey BeeCee,
    I tested this on top level menu items and sub items and found that this is working correctly.
    Please note !is_user_logged_in is for users that are not logged in, so whem you test use a incognito tab so you are not logged in.

    Best regards,
    Mike

    #1411830

    Hi Mike,

    thank you very much for your explanation, I understand and tested it in an incognito tab + I had to disable the maintanence mode of ENFOLD, then – in incognito tab – the draft pages are hidden.

    Thanks, work fine with the snippet above, you can close this ticket.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Hide draft pages and posts from menu’ is closed to new replies.