Move the WordPress page links to the header

The default theme for WordPress places the links to pages in the sidebar. Moving them to the header is relatively easy to do if you’re comfortable making minor changes to the code.
The first thing is to find the path to the theme that you are using, for the default theme the path is:

⁄wordpress⁄wp-content⁄themes⁄default

For other themes the path will vary so make sure you have identified the correct one for the theme you have in use.

Then using your favourite text editor open up the following files:

  • sidebar.php
  • header.php

Note: Before you make any changes to these files make sure you have a backup

Next look for the following code fragment in sidebar.php which is used by WordPress to generate the list of page links.

<ul><?php wp_list_pages('title_li='); ?></ul>

Copy the line of code above from the sidebar.php file and paste it in to the header.php file

This will copy the page links from the sidebar to the header. The end result may look strange because of the CSS styles in use. To get the result seen above in the header of this blog I changed the stylesheet to make the page links float right, where you place them is down to personal preferences.

This entry was posted in Design, WordPress and tagged , . Bookmark the permalink.

8 Responses to Move the WordPress page links to the header

We would love to hear from you so please leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.