
If you know what a Style Sheet is and know that SEO rules, then you should know that the safest way to iconize a menu item or style each page/post list items with a different image/graphic/icon is by its slug, since it’s the only thing that you will ALWAYS keep the same, or search engines would lose your page’s index and value.
There’s a limitation on current wordpess version that removes post-title and post-name from menu-items in database, to prevent them to be confused with the actual page. Yes, they are stored in the same table, and until all the functions are revised to be safe not to confuse nav-menu-items with posts or pages, you can’t get the name nor title nor url! Not with single wp template tags.
Although WP considers the ID of the post as the more safe and CONSTANT piece of data you can use to refer your article as, but that’s inside your WP installation, not extensible to the real world. The post or menu ID could change due to several factors like backing up your site, moving domain, replacing page, new menu items created, etc., but there’s something you will NEVER allow to change: the PERMALINK.
Consequences of changing the url of your post are so severe, that our best clients are those who let their website in hands some hacky guy who promised?miraculous rankings on search engines and they lost 50% of value (for a company depending on 2M internet sales).
Post and Menu IDs could change, breaking the link with your Style Seet rules, and losing your custom logos.
You might want to rather pay extra your developer to keep permalinks the same, than IDs.
So now the most SAFE and CONSTANT piece of data, for you, is the permalink, not the ID. You should do ANYTHING to get it done this way, regardless of what your programmer says is safer. He works for your Google rank, not for WordPress, so listen to me, not them.
After banging my head for days trying to get a solution for this, I realized nobody does it because WordPress doesn’t provide the data (yet).
If you are a WP guru, or a coder monkey like me, check the article about this plugin’s release for the code what will allow you to hack that wp class that can’t get the title:
If you wouldn’t hack your .php files, here’s a ready-to-use plugin, soon to appear in WordPress pages.
It’s very simple, but it adds your page / post’s slug ( sanitized-name-of-your-page ?or ?your-manually-entered-permalink ) to the class of the li that contains it. It also takes a little bit until your SEO defines the right permalink for your posts and you will still have to re-adjust the Style Sheet after his changes (until next release when this plugin will keep track of changes) but once the permalink is defined (they should be defined before making the post live, anyway) your icon / style will remain together with your menu item, regardless of the above scenarios where your post ID could change.
Adds a pagenamed_name-of-your-page class to each menu / list item for you to style them different, working-around WP limitation on not saving page name or title or url of the related page in menu items DB rows.
Better than using IDs, since the permalink MUST stay FOREVER for Google indexing, while menu and page ID are important only inside WP database.
Don’t forget to rate it and tell it works! 〉〉〉〉〉〉〉〉〉〉〉〉
Easy: Install and activate. No options yet (future releases will)
Check out PageNamed Menu Classes plugin page for bug reports, updates, help, and to find other interesting plugins.
Download & install the zip archive
The plugin package installer can be downloaded from the WP2E project tab called “code”.
1 – Select the version to download if this option is available otherwise the “latest” version of the main plugin will be used.
2 – After downloading the zip archive install the plugin package installer in you local environment and activate the script from the plugin list.
3 – Under the section “Plugins” of the admin dashboard you should see a new “Dependencies & Licenses” link. Follow the instructions from this panel to finalize the installation of the missing dependencies.
Tips: Use the WP2E panel to add/suggest new dependencies to the local installation. Press F5 in the list of dependencies if the changes are not displayed right away.