WordPress.org

Plugin Directory

Category Posts in Custom Menu

Dynamic menus: List all posts from a category in your menu. Also works for tags, custom taxonomies as well as pages and custom post types.

How do I use it?

Here's a walkthrough:

  1. Enable the Twenty Eleven theme.
  2. Disable all plugins except Category Posts in Custom Menu.
  3. Create a post with title "Post 1" and add a _new_ category "Category A"
  4. Save the post
  5. Go to Appearances > Menus
  6. Click "create a new menu"
  7. Add the category "Category A" by opening "Categories", checking that category and clicking "Add to menu"
  8. Open the menu item and check "Create submenu containing links to posts with this tag."
  9. Do not change anything else about the menu item
  10. Scroll all the way down and check under "Theme Locations" the checkbox "Primary Menu"
  11. Save the menu

If you now look at your blog, you will have a menu with only one item: "Category A". If you hover over that item with the mouse, it will open, and a post is displayed titled "Post 1". Add additional posts to Category A and you will see these additional posts in the menu.

Missing CSS classes

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 issues

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

$my_cached_menu = get_transient( 'my_cached_menu');

if( $my_cached_menu === false )

{

$my_cached_menu = wp_nav_menu( ... );

set_transient( 'my_cached_menu_', $my_cached_menu, YEAR_IN_SECONDS );

}

echo $my_cached_menu;

Compatibilty

When another plugin or theme, other than CPCM, has a higher priority than CPCM and overwrite sthe fields in Appearances > Menus, this means CPCM's fields won't show. (Verify by disabling all plugins and check if the CPCM fields now show.)

There is no way to go around this with native WordPress hooks. A proposed solution is for all plugin and theme users to start calling and using a custom hook. CPCM does this. The proposed hook is wp_nav_menu_item_custom_fields. Several plugin authors are using this hook. If another plugin is not compatible, contact the author and request they start using this hook. Also see https://core.trac.wordpress.org/ticket/18584#comment:62

Can't see it working in any way

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."

This problem should only occur if:

  • Your WordPress version is 3.0 or before: Issue 14527 (http://core.trac.wordpress.org/ticket/14527) may be the cause. When adding a menu item but before saving it, you will indeed see none of the promised checkboxes. So be sure to save your menu after you add a Category/Tag to your menu. Then you'll see the added functionality. Please update your WordPress version to at least 3.0.1.
  • You're using an old version of Category Posts in Custom Menu. Please update to the latest version of CPCM.
  • Other theme or plugin conflicts. 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.

Requires: 3.2.1 or higher
Compatible up to: 4.4.4
Last Updated: 6 months ago
Active Installs: 7,000+

Ratings

4.9 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

0,1,0
67,3,2
100,2,2
100,1,1
100,1,1
100,4,4
0,1,0
50,2,1
100,1,1
100,1,1 0,2,0 100,1,1
100,1,1
100,1,1 100,2,2
100,2,2
100,2,2
67,3,2
100,2,2 100,1,1
100,1,1
100,1,1