Description
NEW: CPCM V3 now provides support for Full Site Editing with the Gutenberg Block Editor
This plugin is available as Free and as Premium version.
How to add posts to your WordPress menu
You’ve searched online for information how to add posts to your WordPress menu. And all you could find is how to manually add ONE post to the menu… Great. So every time I post something, I have to manually add the post to my menu? Ugh.
But wait! What if WordPress could automatically add the last 10 posts you created to your WordPress menu? Yes, there’s a plugin for that and it’s called Category Posts in Custom Menu.
Here’s how it works:
- Search the WordPress plugin directory for “Category Posts in Custom Menu”, install and activate that plugin
- Go to Post Categories and create a post category, for example “News”
- Go to your menu and add the News category to your menu
- Thanks to CPCM, you’ve now got extra options. Enable the automatic posts expansion
- Now, write a new Post and don’t forget to assign it to the News category
- Go to your website and inspect your menu. Your new post was added automatically!
Do you want more options? The Premium version of Category Posts in Custom Menu supports showing an infinite number of posts in your menu and offers advanced sorting options.
Free
The free version of the plugin can be found in the WordPress.org Plugin Directory. Just search for “Category Posts in Custom Menu”. Or search for “CPCM”, that also works.
Premium
Payment in Euro’s via Stripe or bank transfer (IBAN) to The Netherlands. You’ll receive an automatic e-mail a month before your license expires.
Premium: Features
When you go Premium, you get the following extra features:
- Allow expanding unlimited amount of posts (-1 for unlimited)
- Extra wildcards, see below.
- Build a custom HTML structure for your menu items (no longer only flat text)
- More fine-grained control over how the posts are ordered. (Separate selection of Order By and Ascending/Descending, more fields to order by)
- More fine-grained control over how the posts are expanded. (When to remove the parent item, ability to exclude nested subcategories)
- The ability to extend the plugin with your custom post filtering and wildcards using the CPCM hooks
- Automatic updates
Premium: Actions and filters for extensibility
The plugin behavior can be extended.
To extend the backend with your own controls and use them in the posts query, add the following:
- Filter “cpcm_filter_posts_query”: This filter is called to determine which posts to retrieve for the selected category/taxonomy. You can add or modify the posts query to your liking.
- Action “cpcm_custom_fields”: This hook allows you to add your own input fields to the Category Posts in Custom Menu container in Appearance > Menus.
To add your own wildcards for the post navigation label, add the following:
- Filter “cpcm_replace_user_wildcards”: This filter is called after all default CPCM wildcards have been processed.
You can see examples in the sample-extensions directory, included in the plugin code.
Premium: Screenshots
See product image gallery above
Missing CSS class (WordPress bug)
The CSS class ‘current-post-ancestor’ is not applied correctly. This is a bug in WordPress that I have reported here: https://core.trac.wordpress.org/ticket/32918. This is not something I am able to fix in the plugin, it has to be fixed in WordPress. I’m sorry for the inconvenience.
Performance
The plugin is potentially very expensive, especially when you decide to build your entire menu out of nothing but category posts. The solution would be to cache the menu using transients, as reported here https://wordpress.org/support/topic/performance-problem-many-database-queries?replies=11#post-7829450
Conflicts with plugins/themes
Problem: “I can’t see what effect it has had. Nothing has changed (not that I can see) in the Appearance > Menu page. Just like before.”
If you are using a recent version of category Posts in Custom Menu and an updated version of WordPress, the problem can only occur due to your theme or other plugins conflicting with Category Posts in Custom Menu. Please disable all themes and plugins except CPCM; verify that the CPCM fields show; enable other plugins and themes one by one to determine which plugin/theme conflicts with CPCM.
Note: A theme must either call wp_nav_menu()
or apply_filters( 'wp_nav_menu_objects', … )
for CPCM to be triggered.
You should first check that the Free version of my plugin works as intended, before you purchase the Premium version