PageNamed Menu Classes
Have you tried to style your menu or page list items different and found annoying to update page IDs in your Style Sheets to match your page’s?
WordPress post ID versus Human and Google value
Although WP considers the ID of the post as the more safe and CONSTANT piece of data you can reference your article with, 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.
If you know what a Style Sheet is and know that SEO rules, you’ll understand how important this plugin is. If you don’t, trust me. SEO is the only thing that will make your website live after your ppc campaign dies.
Now, both of you should know there’s a limitation on latest WordPess version that removes post-title and post-name from menu-items in database, to prevent them to be confused with the 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 won’t get the name nor title nor url of the post to use them in your menu item’s class.
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).
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.
There’s an option to MANUALLY identify each menu item in WP menus panel, but you have to do it manually, and again, it could be lost or change respect to your Style Sheet.
Page-Naming Menu and List items
After banging my head for days trying to get a solution for this, I realized nobody does it because WordPress doesn’t provide the necessary data in the posts table (yet).
If you are a WP guru, or a coder monkey like me, here’s what will allow you to hack that wp class that can’t get the title:
get_post_meta( $menuid, '_menu_item_object_id', true);
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 forever, regardless of the above scenarios where your post ID could change.
Download below. Instructions are easy: Install. Period. No options yet. Future releases will.
[downloads_box title="PageNamed Menu Classes"]
You can buy it here, with the button below and I’ll send it to the email address of your PayPal account.
Leave your comments, bug reports or suggestions below.
I accept donations even if you find this plugin not as useful as you expected. In that case, of course, let me know and I’ll try to modify it to suit your needs, if I find some spare time.