January 25th, 2010

Move the WordPress pages to the header – revisited

This updated article describes how to use the page widget to build a page menu in the WordPress header. For the background to this see the previous post Move the WordPress page links to the header that described a simple way of listing the page links on the header.

This method makes use of the Pages widget which allows pages to be excluded from the menu and also allows the sort order of the pages to be specified. To view this from the dashboard expand Appearance in the left-hand sidebar then select Widgets. You can then use the Widget to set up a list of page links in the sidebar.

WordPress Pages widget

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:

  • functions.php
  • header.php

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

In functions.php add the following code in an appropriate place.

function list_pages($pages) {
$options = get_option( 'widget_pages' );
foreach ($options as $key=>$value) {
        if ( $pages == $options[$key]['title'])	{
			$sortby = $options[$key]['sortby'];
			$exclude = $options[$key]['exclude'];
        	if ( $sortby == 'menu_order' ) {
				$sortby = 'menu_order, post_title';
				}
			$out = wp_list_pages( apply_filters('widget_pages_args',
					array('title_li' => '',
					'echo' => 0,
					'sort_column' => $sortby,
					'exclude' => $exclude) ) );
        	if ( !empty( $out ) ) {
				?>
				<li><?php echo $out; ?></li>
				<?php
				}
        	}
		}
}

Then add the following line of code in the header.php file. The correct location will vary by theme but generally it will be within the header div.

<ul><?php list_pages('Header1'); ?></ul>

The effect of this will be to list the pages defined by the Pages widget that has a title of Header1, you can edit the the parameter above for list_pages to match the one you are already using. This should work with WordPress 2.8 onwards but probably will not work with previous versions to that.

June 22nd, 2009

Warning – backup before updating to WordPress 2.8

The first problem with updating to WordPress version 2.8 was with the automatic update facility, the new version comes with it’s own automatic updater built in. This means the WordPress Automatic Update plugin is no longer required and should be disabled. The actual error message will vary according to the Theme that is in use on your site but will start with:

Fatal error: Cannot redeclare pclziputilpathreduction()

After disabling the WordPress Automatic Update plugin and clicking on the Automatic Update link on the dashboard again the update worked correctly. So that is easily dealt with and not a major problem.

The second problem was more serious, the automatic updates had overwritten the contents of the default theme with the original Kubrick design. If like me you have updated the default or the classic themes but never bothered to create a new theme then WordPress will replace your changed files with the originals.

Read the rest of this entry »

April 27th, 2009

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.

Read the rest of this entry »

April 2nd, 2009

Move the WordPress search box to the header

The default theme in WordPress places the search box in the sidebar. Moving it 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

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 search box (What this code does is to insert the contents of the searchform.php file at this point in the page. The searchform.php file contains the code to produce the search box and the search button).

Read the rest of this entry »

March 8th, 2009

FrontPage glitches floor Firefox

In my spare time I like to think of myself as a cyclist, and as a cyclist my thing is riding cyclosportives which are similar if not the same as century rides in the USA. One of the popular rides close to my home in Oxford is the White Horse Challenge which has a route that climbs past several White Horse figures that have been carved into the chalk of the hills around here.

White Horse Hill

The website for this ride was built using Microsoft FrontPage 2003 and looks fine if viewed with Internet Explorer but looks a real mess if viewed with Firefox.
Read the rest of this entry »