If you using wp nav menu you can use this to add the current-menu-item class put this in your theme functions.php file and remember to change “mypageslug” to your wanted current page:
function additional_active_item_classes($classes = array(), $menu_item = false){
global $wp_query;
if ( $menu_item->post_name == 'mypageslug' && is_page_template('archive-expertizeom.php') ) {
$classes[] = 'current-menu-item';
}
return $classes;
}
add_filter( 'nav_menu_css_class', 'additional_active_item_classes', 10, 2 );
This Code adds the class “current-page-item” if you are on a page with the template archive-expertizeom.php
and the menu have a post_name that matches the post_name “mypageslug ie the slug of the wanted page.
Related Posts:
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Archive Page not showing
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Add Settings to Custom Post Type
- Custom post type permalink structure with the category also acting as an archive
- Custom Post Type Works but Still Shows “Page Not Found”
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- Hide child term posts on parent term pages
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Archive page for taxonomy of custom post type
- Add meta data to the custom post type ARCHIVES page
- Custom post type archive sorted and grouped by date in post meta field
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom Post Type archive giving 404
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Custom query variable – get wordpress to redirect to nice permalink url
- Custom-post-type-archive: posts sorted/filtered by year?
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- Add custom post type archives to search results?
- Second Custom Post Type Archive
- How do I get the permalink structure to work like this?
- How to use WP_Query in a CPT achive page?
- Have a Custom Post Type index page display taxonomy items instead of posts
- is_main_query() not working for WP REST API
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Query var removed after rewrite
- Custom Post Type with has_archive ignores my custom archive and single template
- Archives for Custom Post Types (without Pages)
- Set up Custom-Post-Type Author Archive
- Custom post type templating problem
- Extending AZIndex plugin to use custom post types and custom taxonomies
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Custom post type archive page blank
- 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?
- Set thumbnail and title for a post type archive (not post itself!)
- How to set up Custom Post Type archive page as Front page
- How to integrate single and archive templates for custom post type in any WordPress theme
- Show categories of custom post type and not all posts
- adding custom post type “name” to single template
- Custom Post Type with Configurable Sidebar via ACF
- Query Posts that have Custom Taxonomy
- Archive page for custom post type and custom taxonomy
- Order Custom Post Type Archive by multiple values in functions.php
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- How to have multiple archive pages?
- Displaying custom taxonomy menu in custom post type archive
- Create a Custom Path to Archive
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- Display All Courses in Course Archive Page
- Archive page of CPT’s custom Taxonomy
- Getting Same Description in All the Custom Taxonomy Posts
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- Custom post type archive URLs with a single taxonomy
- Custom post type author issues
- Custom Post Type / Taxonomy not displaying archive
- pagination problem listing custom post types of taxonomy in wordpress
- ACF Pro Accessing fields on a Custom Post Type
- Static Front Page not working for custom theme
- Do not show child pages within a file page
- Permalink for custom post type pages not working
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Custom taxonomy with custom post type archive page
- Only show categories that have posts within custom post type
- Meta_query by date for Events archive
- Custome post type “tags” pick default archive instead of custom post type archive
- Customize url from the_terms
- Want to display my custom date archive to date.php but dont know how
- Help with Multi Level Category Archive Page
- Custom post type archive page not showing on archive-posttype.php
- Highlight a Post on archive page if it has a new comment?
- Display custom post type archive on page.php template
- Pagination fault in custom post type archive page [duplicate]
- Templates list in “Page Attributes” metabox is inaccurate
- Stop Custom post type from being searched via URL
- Permalink of custom post type partly broken
- Custom Post Type Archive Links Not Working
- CPT archive as home page
- Archive page of filtered posts
- Why is this custom post type defaulting to archive.php?
- title tag for custom post type remove taxonomy name from title tag
- Archive Page Pagination not working
- Custom taxonomy archive page not routing?
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- has_archive for default post type
- Pagination not working for archive
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Pagination not working only on Archive-Name.php using new WP_Query
- Can’t add custom post type archive page to menu