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
- Display CPT taxonomies as an archive page
- Custom Post Type not using correct page template
- Change CPT permalink to use the category
- CPTUI rewrite disable when no post in CPTUI has been found
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Custom Post Type parent/child relationship rewrite rules for permalinks
- Rewrite of Custom Post Type doesn’t work with dynamic data
- Add %post_id% to slug of custom post type and prevent the “unique slug” thing that WP does?
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Redirect Custom Post Type from Child Taxonomies
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- add_rewrite_tag broke permalinks that doesn’t use that specific tag
- Rewrite url for custom post type with specific url
- Customise Permalink Structure For Custom Post Types
- Custom post type structure + permalink structure
- Set archive of custom post type like ‘posts’ page in reading settings is set
- How to use a custom post type as child of a particular post of another CPT?
- How to make “single post” permalink maintain it’s sub-page structure
- Custom Post Type canonical link / pagination redirecting to root
- Rewrite URL of Specific Post of Custom Type
- Using get_post_type with a custom URL format?
- Automatically add CPT UI categories to the menu
- Custom post type category link + add to menu
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom taxanomy and custom post type – pagination leads to 404
- Register post type getting error 404
- Flush rewrite rules when new cpt is registred
- Rewrite url post_tag for custom post type
- How to build overlapping custom post_type and taxonomy rewrites without conflicts?
- Possition a Custom Post Type Tab under Settings
- Two CPT: one is using part of the custom rewrite slug from the other
- Navigation not working for custom post type pages
- wp_nav_menu doesn’t seem to work on custom post type pages
- Custom post url in search.php isn’t the correct rewrited url
- Custom post type rewrite and wp_pagenavi interfering with each other
- how to display notifications in the wordpress menu when a new post is published
- Show index and not the archive for “Dog Custom Post” with default slug
- I have a custom taxonomy assigned to two post types. How do I create URLs for different term archives for each post type?
- CPT url rewriting : regular posts return 404 error
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- WordPress custom post type rewrite rule matches all pages returning 404
- Remove custom post type slug but keep related category taxonomy permalink
- page not found for example.com/custom-post-name
- Rewrite Endpoint Url without ? before endpoint
- Force WordPress to only match URL in category
- Custom nav menu current item custom link problem
- Paging not working for hierarchical custom post type
- How Can a CPT in WordPress have a page 2 without an error?
- Menu disappears with custom post type link
- Use the page picker from wordpress menu creation page
- How to display custom post type in a submenu?
- Custom post type with parent page? Possible?
- Custom Post Type parent slug as menu item
- redirect old post type url to new structure url
- Custom Post Type URL Rewriting
- Calling the first & last post by category in custom post type
- Remove sequential number from permalinks
- add current-menu-item to multiple custom post types
- Custom WordPress URL
- One custom post type with two different url structure base on taxonomy term
- Archive page for a custom post type using WPML
- List all posts from custom post type by taxonomy
- Nav style for current page with custom post type
- Admin menu post type
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- Why won’t this rewrite rule work?
- Customizing the custom post type permalink
- How to display the FAQ Archive page in my menu
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- Parent cpt/child custom post type URL permalink relationship
- how to override menu widget?
- Cannot modify a registered custom post type rewrite slug
- Custom Taxonomy Showing in WP Menu
- Customize category URL
- Custom Post Type Rewrite Rule
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- Plugins for putting Custom Post Types into the Menu
- No Current Class showing in Menu for Custom Post Types
- Custom post type in submenu with custom meta box as a title with custom html
- CPT Archive with parent page
- 2nd and 3rd Custom Post Type URL’s 404ing
- rewrite rules add a folder in the path
- Getting (Invalid) when adding custom taxonomy of custom post type link in menu [closed]
- Custom Post Type – Rewrite slug [duplicate]
- Custom post type and custom taxonomy archive inaccessible
- Generate daily archive whenever any post type is added
- How can you preserve URLs when moving posts to a custom post type?
- Generating custom URL before post is published
- Setting a Master Menu on a Custom Post Type
- Show posts of parent in edit.php
- Custom Post Type Base URL
- Custom Taxonomy in Permalink from post type
- Rewrite rules for using the same base slug for multiple content types
- Custom Post Type and single-posttype template
- current_page_item and custom post type?
- Custom post type permalink structure
- and custom post_types to custom menu
- Menu that shows months and filters posts to show only posts from that month and shows posts as sub items