How to add navigation to your sidebar in WordPress

The sidebar of a website is traditionally used to place navigation links for visitors to find their way around a website. In WordPress, there are three basic navigation types: Pages, Archives, and Categories. You may add these to your sidebar to help your visitors be able to find content on your site more easily. You can modify your sidebar file to add navigation to these content types. Below are the instructions on how to modify your sidebar to add navigation to your WordPress site.

  1. Log into your WordPress Admin dashboard.
  2. Once logged into the Admin area, look to the left hand menu and click on the Appearance menu category. This will reveal several sub-options. Click on the Editor option to continue.
  3. You are now on the main Editor page for all php and css files for your theme. Look to the menu on the right-hand side, scroll down until you see the Sidebar option. Click on that link to open the sidebar.php file in the editor.
    select editor menu option

  4. Once the file opens you will see the php code that governs the sidebar display and behavior. From here you will be able to add the code to populate the sidebar with navigation links for Pages, Categories, or Archives. Below are the code samples you would need to add to your sidebar.php filePages

    <?php wp_list_pages('title_li=<h2>Pages</h2>'); ?>
    list pages code


    <?php _e('Categories:'); ?> <ul> <?php wp_list_cats(); ?> </ul>
    code to list categories


    <?php _e('Archives:'); ?> <ul> <?php wp_get_archives('type=monthly'); ?> </ul>
    code to add archives

  5. Insert your code into the appropriate spot in the file editor. After inserting the code, click on the Update File link to save you code. From there you can visit your site to see the additional navigation links you have added. You are able to adjust the formatting (font, etc) by adding inline custom CSS or adjusting your style.css file.

Was this article helpful? Let us know!