12

Here are these submenu items under the Posts menu

enter image description here

I inspected the code and found out that the markup of it is this

<ul class="wp-submenu wp-submenu-wrap">
  <li class="wp-submenu-head" aria-hidden="true">Posts</li>
  <li class="wp-first-item current"><a href="edit.php" class="wp-first-item current">All Posts</a></li>
  <li><a href="post-new.php">Add New</a></li>
  <li><a href="edit-tags.php?taxonomy=category">Categories</a></li>
  <li><a href="edit-tags.php?taxonomy=post_tag">Tags</a></li>
</ul>

What I would want to do is add a custom class my-custom-class on the <li> tags (processed on the server-side) such that it would become like this

<ul class="wp-submenu wp-submenu-wrap">
  <li class="wp-submenu-head" aria-hidden="true">Posts</li>
  <li class="wp-first-item current my-custom-class"><a href="edit.php" class="wp-first-item current">All Posts</a></li>
  <li class="my-custom-class"><a href="post-new.php">Add New</a></li>
  <li class="my-custom-class"><a href="edit-tags.php?taxonomy=category">Categories</a></li>
  <li class="my-custom-class"><a href="edit-tags.php?taxonomy=post_tag">Tags</a></li>
</ul>

Is there a way to add a custom HTML class name to admin screen submenu items?

Abel Callejo
  • 13,779
  • 10
  • 69
  • 84
  • 1
    That ripple effect is done using JS so my JS resolution should work just fine as the effect won't work before JS is loaded – Jack Apr 23 '17 at 15:42
  • @JackNicholson I'm not so sure for now. The ripple effects work by appending new DOM objects with in the specific class name. The class name acts as markers on which doms need to have a ripple effect. The javascript library for the ripple then attaches those doms to the marked doms. As long as the footer script gets executed first before the the material design script/library, it may work. I'm gonna have to test it. – Abel Callejo Apr 23 '17 at 15:49