Hot answers tagged

2

First off, you should not register functions loose in functions.php because you cannot remove them (using remove_action). It can also cause debug errors since WP may not yet be stable. By using a hook you are making sure WP is stable enough to run your code, and what you need to use has been loaded. Check out the answer on the Wordpress Forums for more info ...


1

The docs for register_nav_menu show an example using the after_setup_theme hook so I would use that. after_setup_theme This hook is called during each page load, after the theme is initialized. It is generally used to perform basic setup, registration, and init actions for a theme. ...the after_setup_theme hook, which runs before the init hook. The ...


1

There are a few ways to do this and they mostly revolve around the walker_nav_menu_start_el filter. I'd be inclined to add custom fields to the nav menu items: one for the image and one for the image's alternate text. That way, users can update the images and developers aren't required to keep a hash of all menu items and related image URLs/alt text in code ...


1

You can use them the moment they are available i.e. as soon as functions.php is loaded, hence why you've seen so many different options. I would recommend sticking with the "defacto" way - using the hook after_setup_theme



Only top voted, non community-wiki answers of a minimum length are eligible