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);

For dummies

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.

Download PageNamed Menu Classes

Downloads Box by

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.


  1. Hello Sergio,

    Currently I’m using your plugin with WordPress 3.3-RC1 and it works amazing! (rated it and all at

    However, would it be possible to also remove the id from the list perhaps?

    Best regards,


    Cor van Noorloos
    December 2, 2011
    1:12 pm

  2. I can’t think of a total way right now, since the same function that builds the ul also builds other lists.
    If you are talking about each list item id, not the ul id, values could be cleared leaving id=”’ class=”” in them. Would that work?

    Sergio Zambrano
    January 13, 2012
    7:54 am

  3. It seems this only partly works lately. as shown here it did not grab the slug. This is just a category on a nav menu. Thank you for your work.

    September 30, 2013
    1:57 pm

  4. It seems it did. The .jpg image name there is the slug. This link item seems to belong to an attachment post. Isn’t? Can you send me a link to the site?

    Sergio Zambrano
    October 9, 2013
    2:59 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment