This is what you want to do,
add_filter( 'wp_get_nav_menu_items', 'cpt_archive_menu_filter', 10, 3 );
function cpt_archive_menu_filter( $items, $menu, $args ) {
foreach ( $items as &$item ) {
if ( $item->type != 'custom' ) continue;
if ( get_query_var( 'post_type' ) == 'your-post-type' && $item->title == 'Title of Link' ) {
$item->classes []= 'class-name-your-want';
}
}
return $items;
}
Although the above will work, Custom Links get assigned the current-menu-item
class so this shouldn’t be necessary, if I follow you correctly.
Related Posts:
- Adding a menu item for a Custom Post Archive
- Adding custom post type archives to a WordPress menu
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- How can I use archive-{post_type}.php theme template?
- How to display the FAQ Archive page in my menu
- CPT Archive with parent page
- Can’t add custom post type archive page to menu
- Unable to get post archive link
- get the custom post type title/name
- CPT custom archive template does not get loaded
- Custom post types and tag archive pages/permalink structure issue
- Custom post type templating problem
- Correct classes for WordPress menu items
- Custom Taxonomy Navigation, with current menu items for children?
- Custom post type is showing custom home page, not archive page
- Displaying Page as Custom Post type landing Page
- Customize the Dashboard Menu Editor
- URL of a custom post type’s post format archive?
- Custom Post Type archive loop separated by term, in specific term order
- Display posts from Custom Post Type in category page on front-end
- Use menus with anchors
- How to make this menu drop down or like accordion
- Show only posts from one category on custom post type archive page
- Customize my custom taxonomy table in Admin panel
- Custom Post Type Nav to Subpage
- Create template for taxonomy results limited by Custom Post Type
- How should I structure my post types?
- Custom Post Types don’t highlight in menu nav
- Querying both pages and posts
- Using default WP menu functionality to link to custom post-type listing?
- Extending AZIndex plugin to use custom post types and custom taxonomies
- How to use has_archive but disable feed per post type?
- Custom post type: Disable single page, but keep archive
- WordPress post_where & posts_join not working only for custom post type
- Second Set of Eyes: One custom taxonomy shows in Appearance > Menus, one does not
- Use Custom Post Type archive page for the taxonomies term archive page
- Display custom post type category, while in a CPT category, then the posts beneath
- page menu entry for custom post type
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- CPT archive admin menu label
- Number of Custom Post Types published are not being shown in the custom page
- How to display custom WP menus?
- How to Create Columns with WordPress and CPTUI display page ?
- Custom post type archive page blank
- Custom Post Type has_archive
- Custom Post Type Archive URL is wrong
- Creating a Custom Post Type
- Custom Post Type slug same as page name
- How to display custom post in archive section of the wordpress page?
- Content Editable CPT Archive?
- list archives per post types
- Canonical url differs from custom post type archive URLs
- Display a custom posts page for post type
- Custom post type archive pagination 404
- Is there a way to establish parent/child relationship in WP menu links exclusively?
- posttype/taxonomy/term archive page 404 error
- Is it possible to have a custom post type with feed but without the archive?
- Use custom walker to add taxonomy terms to main nav menu
- A page that shows a list of a specific custom post type
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Single custom post type’s menu ancestor/parent is Posts archive page
- menu link to custom post_type?
- Review site custom post type structure
- Paginate_links in custom post type template
- Custom Post Types in the WordPress Navigation Menu
- My archive-posttype.php template is not loading
- Redirect to another page using contact form 7? [closed]
- Custom Post Archive is not working
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- Custom post type archive with page as parent url
- Add parent post to Custom Post Type [closed]
- Set featured image to archive.php
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Ordering Submenu Pages in WP 3.1
- Including link to custom post type in ‘wp_list_pages’ function
- What’s the name of the custom post type yearly archive template?
- Custom post type, global categories — what’s the template name?
- Which Template Page Should I Use?
- How to hyperlink content from archive page with custom post-type
- How can i automatically add CPT single pages as sub menu items
- Set thumbnail and title for a post type archive (not post itself!)
- How to set up Custom Post Type archive page as Front page
- Url to archive page for custom post type
- Add custom CSS class to custom post type
- How to display CPT archives?
- Custom meta Title for custom post type archive from page
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- Custom Post Type Link added to menu won’t show in frontend
- Return the name of the post type
- How To Display A List Of CPT Posts In A Meta Box On Menus Page?
- Give each post type label a different color?
- Get custom post type categories to show up in menus
- How can I create an automatic drop down menu with my tags?
- show current item in custom menu, when inside a custom post type
- current-menu-item not added on page showing custom post type (rendered with archive template)
- Alphabetically sort a taxonomy.php template by post title
- WordPress menu with custom taxonomy
- Prevent custom post type from showing up in custom menus
- Displaying custom post types as a gallery
- Custom Permalinks For CPT and pages with parent. Advanced WordPress