I’ve got the filter just for you: nav_menu_css_class
function wpse_175057_nav_menu_css_class( $classes, $item ) {
if ( $item->type === 'post_type' && $class = get_post_meta( $item->object_id, '_icon', true ) )
$classes[] = $class;
return $classes;
}
add_filter( 'nav_menu_css_class', 'wpse_175057_nav_menu_css_class', 10, 2 );
Related Posts:
- Apply the_title() filter in post & page title, but not in menu title
- Adding Post Counts to Menu (Nav) Programmatically?
- Is it possible to show a different WP menu when using password protected pages?
- Edit menu item title from edit page/post
- Disable most recent & view all (TABS) on nav-menu.php
- Using wp_list_pages() after calling query_posts()
- disable Tab post on nav-menus page (Admin)
- Making a new post visible on a specific page
- Featured Images most often doesnt appear
- Go back to the exact post page number
- Parent menu item does not display posts when I add the sub-items
- Using WP page password protection as defacto login
- I lost the link to my posts in my menu bar
- Page and Posts loading as index page? Not loading the content
- Call posts of particular category in a page
- How to make posts appear under pages
- Adding a post to a page
- When changing pages to posts, how do you set up 301 redirects for the page URLs?
- Display Posts on Custom Page
- Show posts count for Categories and Tags in wp_nav_menu
- How to add category post count in main navigation menu [closed]
- User Selectable Delete of Pages
- 2 dynamic sidebars registered, not showing up
- Multiple Loops Breaking Pages
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- How to get ID of the page included with get_page()?
- Posts vs Pages and categories
- Including link to custom post type in ‘wp_list_pages’ function
- How to dynamically parse and transform post/page content before displaying it?
- How to make default “Privacy Policy Page” a normal page?
- Customize rel=canonical tag for single blog post
- Change all author links in Blog roll
- How to I retrieve the ID from the Posts page?
- How to save meta checkbox WordPress
- Proper way of establishing custom landing pages in WordPress
- Parsing Menu Items and Blog Posts
- How to Use index.php file for “Blog” Page And this is Not a Home Page
- How to calculate the average of a post meta value(Numeric) of a specific author
- is_page Funtion for Posts ?
- Is there any way to tell when wp_postmeta has been updated?
- is_page() and is_page_template() not being differentiated
- Admin – no Featured image choice in create new/page|post
- How to detect when admin user is on the All Posts page?
- static landing page leading to author specific pages w/ “live” content
- wpColorPicker – problem with implementation to post meta
- Total number of posts in query (category/tag/author/search results/main page…)
- Custom Permalink Structure for Pages & Posts
- Getting a “404 Not Found” error when “Preview Changes” is clicked
- Why won’t pagination work?
- How can I list posts by author?
- WordPress Query Posts From Category Post on Static Page
- How to create a “latest news” page showing a list of posts from blog category
- WordPress Menu options in the Admin: Posts for the dropdowns
- Is there a way to add the list of recent posts into the admin sub menu on hover?
- Automatically add images to a menu
- How do you search for a post or page with a certain url on the WordPress admin panel?
- Change post author without using wp_update_post()
- How to add some html formated text to every new post in WordPress
- if in category but only with post meta
- Insert menu with a custom walker into page / post body using shortcode?
- Intercept page request and add value to it
- wp_query with ajax
- Update post meta within save_post action
- WordPress 302 Redirect to Random Product/Post/Page
- Display post number by category
- Output Post with ACF Fields into other Post
- How to create a page that shows the last 10 posts?
- Updating post meta for checkbox
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- $_GET parametters not working in an specific template
- Saving Post Data in Another Database
- New Posts and Pages Won’t Save
- My Custom Post Type Still Using index.php
- get_children returns older images
- Posts and Pages: 404 Page not found
- WordPress post filter menu
- Custom permalink for each post
- the_content() Not Grabbing All Content
- How can I tell if a post has been published at least once?
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Is there a way getting post fields using `transition_post_status`
- Display Featured Posts Grid on Static Page (Gazette)
- Automatic blog page with custom design [closed]
- Detecting current page from class method
- Add multiple meta keys to a post at once
- Having pages after specifying post_type post
- Show number of posts by logged in user
- How does WP decide how to display a page
- Unabled to Change Permalinks – Even Using the “Edit” (Resets to Original Permalink on “Update”)
- List all posts, pages and custom post types in admin
- Make ‘blog’ page show content as well as posts underneath it
- I don’t want the complete article to show on homepage
- Get current post’s nav menu name (term name)
- Post/page title to permalink transformation – what is behind the scenes?
- When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
- Change Author Name to Sitename on Frontend
- Would a “hub” page work better as a page or a post?
- Display on page every post in blog WITH comments
- Are post, page and category IDs unique to each other?
- Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT