Ended up hooking the nav_menu_css_class
filter, and adding the appropriate class when needed.
Like this:
add_filter( 'nav_menu_css_class', 'add_parent_menu_class', 10, 2 );
function add_parent_menu_class( $classes, $item ) {
$post = get_post();
if ( ! $post ) {
return $classes;
}
if ( $item->url === get_bloginfo( 'url' ) . '/custom_url' && get_post_type() == $this->post_type ) {
$classes[] = 'current-menu-parent';
}
return $classes;
}
Related Posts:
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- Removing base slug from hierarchical custom post type
- Rewriting ‘rewrite’ slug for custom post type used by plugin
- Adding meta values to permalink
- How can I get my Custom Post Types to appear in nav-menus.php ‘Menu’?
- WordPress custom taxonomy URL rewrite on spelling errors
- How can i avoid the permalink start with ‘blog’ while using the custom post type?
- Custom Posttype Inheritance (and url structure)
- Adding %author% in custom post type URL structure?
- automatically placing custom post types singles into submenu of main nav menu
- Renaming Menu Item within Admin Menu Section for a Custom Post Type?
- How to Programically add to the new WordPress menus
- Defining a default page for custom post type
- Pass parameter to custom post type single while keeping clean url
- Removing CPT slug from URL results in 404 error for archive page
- URL Design for Sub-Posts?
- Many to Many Taxonomies or rewrite rules?
- Remove base slug in CPT & CT, use CT in permalink
- remove post-name from title in custom post type
- Getting Post ID from slug during init
- Rewrite custom post & taxonomy to share same URL path
- how to use two permalinks for one custom post type
- Adding a date archive to Custom Post Type
- Bulk 301 redirect for custom post type
- Editor access to menu: custom post type missing
- Settings page above CPT page in admin section
- Remove current_page_parent from posts page link in WordPress nav menu
- Custom Permalink Tag breaks Pagination
- Menu highlight custom post type archive
- Custom Post Type and Custom Taxonomy Permalinks
- Pagination problem
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Menu Multiple Taxonomies
- Custom Post Type Post have a Child `Page` Post Type Post
- How can I display an archive of only one category of my custom post type?
- remove permalink “front part” for custom post type
- Permalink Structure CPT With Custom Taxonomy Fails
- Query var removed after rewrite
- Change Permalink Structure for Tag.php template
- Set menu active state for custom posttype and category, given custom taxonomy term
- Add archive slug to default post post type
- Custom Post type and permalink settings
- Correct classes for WordPress menu items
- How to make this menu drop down or like accordion
- Rewrite post type slug only for child theme
- Using default WP menu functionality to link to custom post-type listing?
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- How can I make the slug of the taxonomy also the slug of the custom post
- Customize Custom Post Type URL
- How to display custom WP menus?
- Versioned Custom Post Type (Not the same as revisions)
- Rewrite URL of Custom Post Type for Jobs
- Custom post Type, child of a Page?
- Hide or disallow default custom post type url?
- Custom taxonomy returns 404
- Pretty URLs and custom post types
- Specific routing for CPT
- Lost of query parameter when using permalink
- Single custom post type’s menu ancestor/parent is Posts archive page
- menu link to custom post_type?
- Custom permalink with child taxonomy terms
- Custom post type archive with page as parent url
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Custom Rewrite Rule for Custom Post Type with URL Param
- WordPress custom slug rewrite
- How can i automatically add CPT single pages as sub menu items
- WordPress Custom Post Type – Rewrite Query
- Dynamic CPT permalink structure based on ACF field value
- Custom Posttype and menu classes
- Rewrite rules for custom post type
- Custom taxonomy and post type rewrite rules
- Custom Post Type and Taxonomy Rewrite Error
- custom posts permalinks url rewriting
- WordPress is ignoring my post rewrite rule
- Menu for taxonomies and posts belongs to taxonomy
- Url Rewriting a dynamic wordpress page with parameters
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Duplicate content problems after adding an archive page to the article’s post type
- Display CPT taxonomies as an archive page
- CPTUI rewrite disable when no post in CPTUI has been found
- Redirect Custom Post Type from Child Taxonomies
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Register post type getting error 404
- CPT url rewriting : regular posts return 404 error
- Archive page for a custom post type using WPML
- List all posts from custom post type by taxonomy
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- how to override menu widget?
- How can you preserve URLs when moving posts to a custom post type?
- Show posts of parent in edit.php
- Custom Post Type Base URL
- Custom Taxonomy in Permalink from post type
- Custom Post Type and single-posttype template
- current_page_item and custom post type?
- sidebar hierarchical menu category & custom post type