Monthly Archives: February 2011

WordPress: Create and use a second header.php file

Good afternoon friends! Today I want to share a very easy way to incorporate a second header.php file into your WordPress theme.

First, let’s create the second header.php file. Typically, I will just copy and paste the codes of the original header.php file, edit them as I see fit, and then save the new file as my second header.php file.

For this example, I will use just a very simple header. Paste this code into a text editor:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php if ( is_home() ) { ?><? bloginfo('name'); ?>&nbsp;<?php bloginfo('description'); } else { wp_title('&nbsp;'); ?>&nbsp;by&nbsp;<? bloginfo('name'); } ?></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="shorcut icon" type="image/x-ico" href="<?php bloginfo('template_url'); ?>/favicon.ico" />
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascript/imghover.js"> </script>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<?php wp_head(); ?>
</head>
<body>
<!-- header START -->
<div class="Header">
<h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
<div class="Desc"><?php bloginfo('description'); ?></div>
<!-- header END --><!-- container START --><div class="Container">

Now, save  the file as header-secondheader.php (or whatever you want the second header to be called). Just make sure it is in the format of header-yournewheader.php.

Upload the file to the correct folder on your server – ” …/wp-content/themes/yourthemename“.

Next, open the template page that you want to use the second header for. For this example, let’s say it is index.php.  Find this line of code:

<?php get_header(); ?>

And replace it with this:

<?php get_header('secondheader'); ?>

Of course, make sure that the name in the parentheses is the name of your second header.

That should work for you, but as always, let me know if you run into any issues at all.

WP E-Commerce plug in: fixing output from USPS rate calculator

I have used the WP E-commerce plug in for several WordPress online stores that I have developed for clients, and one thing that I have run into more than once is this: the names of the carriers when you calculate USPS shipping rates often have an unsightly line of code in them:

Priority Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; Flat Rate Envelope
Express Mail&lt;sup&gt;&amp;reg;&lt;/sup&gt; Flat Rate Envelope
Parcel Post&lt;sup&gt;&amp;reg;&lt;/sup&gt;

Here is the way to fix it. Open  wp-e-commerce/wpsc-includes/cart.class.php and find this line of code:

function wpsc_shipping_quote_name() {
 global $wpsc_cart;
 return $wpsc_cart->shipping_quote['name'];
}

Replace that block of code with this:

function wpsc_shipping_quote_name() {
	global $wpsc_cart;
	//return $wpsc_cart->shipping_quote['name'];

   $output .= $wpsc_cart->shipping_quote['name'];
+  $output = str_replace('&amp;lt;sup&amp;gt;&amp;amp;reg;&amp;lt;/sup&amp;gt;', '<sup>&reg;</sup>', $output);
+  $output = str_replace('&amp;lt;sup&amp;gt;&amp;amp;trade;&amp;lt;/sup&amp;gt;', '<sup>&trade;</sup>', $output);

   return $output;
 }

Now simply save the file and your problem should be fixed! That has worked every time for me, but let me know if you have any trouble.

WordPress: Changing the default home page title in the navigation menu (Twenty-Ten theme)

Today, while working on a WordPress website, I noticed that when I selected a static page of the site to be the home page, it automatically re-named the page “Home” in the navigation menu rather than keeping the original title of the page.

To solve this, I opened the functions.php file in the admin panel. Then I found this block of code:

function twentyten_page_menu_args( $args ) {
 $args['show_home'] = true;
 return $args;
}
add_filter( 'wp_page_menu_args', 'twentyten_page_menu_args' );

I erased that block of code and saved the file. Now the page shows the title I gave it in the navigation menu – problem solved!

Let me know if you are running into the same issue I was and this tip doesn’t help you, and I’ll try to help you.