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
- How can I retrieve multiple get_post_meta values efficiently?
- how to limit edit_form_after_title hook to page and post edit only?
- Export WordPress Posts and Meta Information in CSV format
- How to add post count to wp_nav_menu?
- Create custom page in WooCommerce
- Change WordPress post-state in Admin Area
- how to show all post in my page-grid.php template page
- eBooks download website, page or post?
- Change post format using custom field
- Can I hide a specific post from latest posts page?
- Hide add new page button
- How to show post(excerpt) from specific category on wp page?
- WordPress menu that shows all posts in a certain category like w3schools
- How To Keep Posts from Being Displayed Two or More Times on My Homepage? [closed]
- Add custom field automatically (add_post_meta) with value based on number of words of article
- Mark menu item as current-menu-item for category
- post-page: reference to parent page?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- Blog Posts in Custom Menu
- Can I divide the pages into categories?
- How do I get blog posts to appear within CMS?
- Drag posts and pages so you can sort them in order
- post categories
- Custom Posts Query and meta_query Sort Order
- One menu for frontpage (one pager), and a different menu for posts
- Calling Different Custom Post Timestamps in a table
- Start post pagination at 0 instead of 1
- How to add category post count in main navigation menu [closed]
- Multiple Loops Breaking Pages
- Proper way of establishing custom landing pages in WordPress
- Parsing Menu Items and Blog Posts
- Is there any way to tell when wp_postmeta has been updated?
- Admin – no Featured image choice in create new/page|post
- Why won’t pagination work?
- Is there a way to add the list of recent posts into the admin sub menu on hover?
- How to add some html formated text to every new post in WordPress
- Display post number by category
- Output Post with ACF Fields into other Post
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- Posts and Pages: 404 Page not found
- List all posts, pages and custom post types in admin
- When sending a newsletter -not with wordpress- the server has 100% cpu [closed]
- Are post, page and category IDs unique to each other?
- Create a frontpage.php and static page template
- How to show next/prev link, when it’s not active?
- Prevent 404 of Author pages without posts
- Cannot publish posts, but can create new pages
- Can I restore restore content from old Worpress site to a new Worpress site from an archive
- How Do I Redirect WordPress Pages but not posts?
- Custom Fields – How to get the list of a specific active widget each time it rendered
- Yoast breadcrumb URL shows category instead of the page
- How to show only homepage in google results instead of privacy, contact pages
- Google indexing duplicate page content with Page #### in post title and /page-2 in permalink instead of the ones I set
- Nestling Posts Under Page & Justify Text
- Show post count in custom taxonomy page
- How to show WP admin edit page within template page/post?
- Blogposting Schema & Structured Data without plugin
- Display all tags even if they are not assigned to a post
- How do you update post date (year only) in a separate custom field?
- Automatic Table of contents with categories and posts
- Very weird behaviour after removing WP pages
- Category URL to use same string as Post URL Permalink
- Grab meta data before post is saved
- Posts on Sidebar only
- How to add content to the menu
- display content in multiple columns
- Hide Admin posts & pages in Dashboard
- Get the correct meta_value with get_post_meta
- structure of posts and pages
- Allow users to create their own page/s
- some posts being displayed as pages
- Make Show Notes for Individual Podcast Episodes Easy to Find (multiple URL’s?)
- Get part of a page url
- can’t post immediately
- Displaying only posts from a certain category on my custom page template
- Where are my posts linked to? I keep getting a Not Found Error, and I have no single.php page
- Custom post page has attributes of latest post [closed]
- WordPress “Posts Page” isn’t showing template dropdown
- Adding Count Post in Page
- How to have 2 posting pages on a blog
- change page name on page list
- how can i get the page_ID in nav li [closed]
- Translation related post text to Arabic