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
- How to remove custom post type archive
- How to use a custom post type archive as front page?
- Page Template as Custom Post Type Archive
- Can’t get post id on page that is a custom post type archive
- Creating “static” taxonomies to choose from, inside custom post type?
- Custom Post Type Menus
- How can I get my Custom Post Types to appear in nav-menus.php ‘Menu’?
- Extend walker class with custom post types [closed]
- automatically placing custom post types singles into submenu of main nav menu
- Get monthly archives for custom post type
- Is it possible to remove the posts_per_page limit on a specific post type?
- How to Programically add to the new WordPress menus
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Assign Page Template Within A Custom Post Type
- Posts per Page on custom Taxonomy Template
- Post type archive page not working
- Custom Post Type – Archive page title
- Archive or taxonomy pages not working for custom post type
- Editor access to menu: custom post type missing
- Menu highlight custom post type archive
- taxonomy template for custom post type the same as the archive
- Display only post types that are direct children of the current taxonomy
- Change post featured image on hover
- Custom post type search with slug in URL
- Conditional tags don’t work
- Add/Remove current_page_parent class
- Custom template won’t load for a custom post type (custom permalinks used)
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- custom post type not showing in menu
- CPT custom archive template does not get loaded
- URL of a custom post type’s post format archive?
- Display posts from Custom Post Type in category page on front-end
- Use menus with anchors
- Custom Post Type Nav to Subpage
- Create template for taxonomy results limited by Custom Post Type
- Querying both pages and posts
- Custom post type: Disable single page, but keep archive
- Use Custom Post Type archive page for the taxonomies term archive page
- Number of Custom Post Types published are not being shown in the custom page
- Custom Post Type has_archive
- Custom Post Type Archive URL is wrong
- 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
- posttype/taxonomy/term archive page 404 error
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Custom Post Types in the WordPress Navigation Menu
- My archive-posttype.php template is not loading
- Custom Post Archive is not working
- Set featured image to archive.php
- How to display CPT archives?
- Custom meta Title for custom post type archive from page
- Custom Post Type Link added to menu won’t show in frontend
- How To Display A List Of CPT Posts In A Meta Box On Menus Page?
- Get custom post type categories to show up in menus
- current-menu-item not added on page showing custom post type (rendered with archive template)
- Alphabetically sort a taxonomy.php template by post title
- Prevent custom post type from showing up in custom menus
- Custom Post type date archive for custom taxonomy
- Custom Post Type Custom Archive Page Not Working
- Getting custom taxonomy posts on archive page
- How to programmatically add elements in a custom menu
- Custom post type category permalinks and archive pages
- Pages not appearing?
- CPT archive with WP native/core tax/categories
- How to add specific terms in a custom post type?
- WordPress Page hierarchy ( parent is singular of custom post types slug ) is returning not found
- cpt not display inside nav menu
- Custom post type not pulling CSS
- Display Custom Post Type Archive content with Shortcode
- Custom Post Type archive page listing a 404 or single post
- Building Link List for Custom Tax
- Unsure what page hierarchy to use with CPT UI to show on front end
- Custom post type category link + add to menu
- get first limited words from a custom post in the archive page
- Navigation not working for custom post type pages
- Custom post types not displaying per category
- How to Show all Values in category.php page using post_type
- Show index and not the archive for “Dog Custom Post” with default slug
- Making a archive gallery page for a custom post type which already has an archive page
- Custom taxonomy in custom post type archive with pagination
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Custom Post Type parent slug as menu item
- How can I retrieve the slug for a custom post type via name?
- paging is not working properly on news archives page [duplicate]
- Multiple search template with separate stylesheets
- Setting a Master Menu on a Custom Post Type
- custom post type not getting archived?
- Menu that shows months and filters posts to show only posts from that month and shows posts as sub items
- WordPress custom post type odd and even styling [duplicate]
- Navigation won’t update to show full path to single post
- Add a class to a menu item depending on a body class