Halloween Sale 15% off Ends in See the plans
CSS

Turn a Menu Item Into a Button

Styles any menu item with the CSS class "menu-button" as a solid call-to-action button, in classic theme menus and the Navigation block.

Don’t have WPIDE yet? Install it on your site

Code

.menu-item.menu-button > a,
.wp-block-navigation-item.menu-button > .wp-block-navigation-item__content {
    display: inline-block;
    padding: 0.55em 1.2em !important;
    border-radius: 999px;
    background: #111827;
    color: #ffffff !important;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.menu-item.menu-button > a:hover,
.menu-item.menu-button > a:focus-visible,
.wp-block-navigation-item.menu-button > .wp-block-navigation-item__content:hover,
.wp-block-navigation-item.menu-button > .wp-block-navigation-item__content:focus-visible {
    background: #374151;
}

Notes

Add menu-button to the item's CSS Classes (Appearance > Menus, enable it in Screen Options) or to a Navigation link block's Additional CSS class. Change the colors here.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.