{"id":51870,"date":"2011-06-21T09:00:15","date_gmt":"2011-06-21T13:00:15","guid":{"rendered":"http:\/\/wpmu.org\/?p=51870"},"modified":"2011-06-21T01:46:53","modified_gmt":"2011-06-21T05:46:53","slug":"highlight-current-page-using-wordpress-navigation-menus","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/highlight-current-page-using-wordpress-navigation-menus\/","title":{"rendered":"How to Highlight the Current Page when Using WordPress Navigation Menus"},"content":{"rendered":"<p>WordPress 3.0 brought us a shiny new navigation system with drag and drop style <a href=\"http:\/\/codex.wordpress.org\/Appearance_Menus_Screen\" rel=\"noopener\" target=\"_blank\">custom menus<\/a>. This added theme feature has been quietly making everyone&#8217;s lives much easier.<\/p>\n<p>Today we&#8217;re going to walk through a basic styling tip for highlighting the current page. This is a helpful little CSS tweak that makes your website easier to navigate.<\/p>\n<p><a rel=\"lightbox[51870]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2011\/06\/current-page.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-51877\" title=\"current-page\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2011\/06\/current-page.png\" alt=\"Post image\" aria-hidden=\"true\" width=\"568\" height=\"99\" \/><\/a><\/p>\n<p>If your theme supports WordPress menus, then you already have a built-in class to make it super easy to highlight the current page being viewed. If you&#8217;re using an older theme that does not offer support for WordPress menus, then you can easily add it in yourself by following the <a href=\"http:\/\/codex.wordpress.org\/Navigation_Menus\" rel=\"noopener\" target=\"_blank\">tutorial<\/a> in the codex.<\/p>\n<p>By default, WordPress menus output this class with the list item: <b>current-menu-item<\/b><\/p>\n<p>You can choose to target either the list item or the link itself. This example specifies the background color and font color for the <b>current list item<\/b>:<\/p>\n<p><code>{code type=css}<br \/>\nli.current-menu-item {<br \/>\nbackground: #3FAEA5;<br \/>\ncolor:#fff;<br \/>\n}<\/code><\/p>\n<p>So simple, right? Here&#8217;s how you might target the link itself:<\/p>\n<p><code>{code type=css}<br \/>\nli.current-menu-item a {<br \/>\ntext-decoration: underline;<br \/>\nbackground:#ccc;<br \/>\n}<\/code><\/p>\n<p>You can add colors, backgrounds, text shadows, background images, or anything you like to highlight the current page.<\/p>\n<p>If your theme supports the creation of multiple navigation menus, then you&#8217;ll need to be a bit more specific in your CSS if you want to have them styled differently.<\/p>\n<p>You can use Firebug to find the unique ID of your unordered list. It will contain the name you gave to your menu.<\/p>\n<p>If you have other menus with different styles on the page, then you&#8217;ll need to differentiate them in your CSS:<\/p>\n<p><code>{code type=css}<br \/>\n#menu-main-pages li.current-menu-item {<br \/>\nbackground: #3FAEA5;<br \/>\ncolor:#fff;<br \/>\n}<\/code><\/p>\n<p>With those simple snippets you should have the basics for highlighting current menu items.<\/p>\n<p>Have fun styling your custom menus and let us know if there are any more CSS tutorials you&#8217;d be interested to see on wpmu.org.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress 3.0 brought us a shiny new navigation system with drag and drop style custom menus. This added theme feature has been quietly making everyone&#8217;s lives much easier. Today we&#8217;re going to walk through a basic styling tip for highlighting the current page. This is a helpful little CSS tweak that makes your website easier [&hellip;]<\/p>\n","protected":false},"author":4099,"featured_media":182830,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[1,263],"tags":[1044,87],"tutorials_categories":[],"class_list":["post-51870","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news-community","category-tutorials","tag-css","tag-menus"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/51870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/4099"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=51870"}],"version-history":[{"count":2,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/51870\/revisions"}],"predecessor-version":[{"id":182828,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/51870\/revisions\/182828"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/182830"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=51870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=51870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=51870"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=51870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}