Tag: WordPress

  • Get WordPress menu items only (not the whole menu)

    You might find yourself in the situation where you need to get the menu items for a particular WordPress menu without grabbing the whole menu markup (for example, the nav part) itself or maybe you just want get the menu items data to output in your loop elsewhere.

    Render the menu items without the nav

    In the first scenario, we can render the menu without the container (usually nav) by using wp_nav_menu() and setting container to be blank.

    https://gist.github.com/nickdavis/aa2cf126384a3550940767688b8f8959

    In this example we just need to know the slug for the menu location we’re targeting.

    Get the menu items data and render in a custom loop

    In the second scenario, we can grab all the menu items data by passing the menu’s slug (rather than the menu location slug) to wp_get_nav_menu_items() like the following example.

    https://gist.github.com/nickdavis/9947bc968903549afc3950d80db796b7

    (For this technique you might need to get a WordPress menu from a specific menu location in order to discover the correct menu slug).

  • Get a WordPress menu from a specific menu location

    Sometimes you know that you want a WordPress menu associated with a particular menu location, but you don’t know for sure which menu is associated with that location.

    To find out which menu it is (I typically want to know the slug) you can do something like the following.

    https://gist.github.com/nickdavis/25d4a733b7c2754ca1e34db31a735bb0

  • Get Post Slug in WordPress

    Get Post Slug in WordPress

  • NoIndex all posts in a WordPress category

    https://github.com/Yoast/wordpress-seo/issues/387#issuecomment-48589725

  • WordPress FTP access without login details (via a plugin)

    Sometimes I find myself in the situation where I need FTP access to a WordPress website and – although I have access to the WordPress admin itself – I don’t have the FTP login details for the website.

    Often this is because the person I’m helping is not sure how to get the FTP access details (or can’t easily get them) or maybe it’s urgent and there’s no time.

    In those circumstance I found this File Manager plugin useful. It gives you FTP access to the site but via the WordPress admin.

    There are also others available in the WordPress plugin repository, but this one has worked best for me from the ones I’ve tried (if you know of a better one add it in the comments!).

    Of course, this is very much a last resort or emergency option, but it’s good to have one.