I’ve packaged-up a plugin that I wrote a while ago for a project that I worked on which required a WordPress site’s menu items to have a separately addressable excerpt field which could override the linked page’s in-built excerpt.
The plugin that I’ve now released was half of the resolution to this requirement, which allows for simple programmatic field additions to the menu system.
Custom Menu Fields is available at the WordPress.org plugin repo.
To use this plugin all one needs to do is install and activate the plugin as normal and then include a snippet similar to below in their theme’s functions.php (or custom plugin code. Just be sure it loads earlier than the ‘init’ action!):
|
|
Now you can get access to the ‘excerpt’ field by using the attribute on the menu variable you assign when you get the menu from WordPress.
e.g. to print the excerpt created above:
|
|