How to Create Multiple Page Layouts Using One Page Template in WordPress

wordpressWe are using WordPress as a CMS for a client who needed a 3 column layout for all the pages except one. This one page needed a full width content without any sidebars. Instead of using a different template for this one page, I decided to use PHP conditionals..

First, set the div for the content, depending on which page is displayed. The page we are removing the sidebars for is “short-sale-listings-phoenix”. Don’t forget to set the styles in style.css.

<?php  // display full width content or normal width content for 2 sidebars
	if (is_page('short-sale-listings-phoenix')) { ?>
         // display full width content
	<div id="content-wide">
	<?php } else { ?>
        // display narrow width content for use with sidebars
	<div id="content">
    <?php } ?>

Second, add or remove the sidebars.

<?php  // display sidebar or not
	if (is_page('short-sale-listings-phoenix')) { ?>
        // display no sidebar
    <?php } else { ?>
       // display sidebar
    <?php get_sidebar(); ?>
<?php } ?>

<?php  // display sidebar or not
	if (is_page('short-sale-listings-phoenix')) { ?>
        // display no sidebar
    <?php } else { ?>
      // display sidebar
    <?php get_sidebar('right'); ?>
<?php } ?>

That’s it.

Resource: If you need more help, here is a great article by Darren Hoyt Multiple WordPress Page Layouts in One Single Template.

How Email Marketing Can Benefit Your Company

Mail Bagg'sv2Excelnet Media is now offering Email Marketing monthly service plans.

The Direct Marketing Association’s research shows that email marketing is expected to generate an ROI (Return on Investment) of $43.52 for every dollar spent on it in 2009. Compared to all other direct marketing channels, email marketing outperforms them all.

How can Email Marketing benefit your company?

  • Increase your sales conversion – Most visitors to your website won’t convert to a sale on their first visit. Research shows that the average customer will visit a website 9 times before they buy. Once you have their email address you can keep your company in front of them by sending email newsletters.
  • Increase sales from existing customers – It can cost 8 to 10 times more to acquire a new customers than to sell to an existing one. Keeping in touch with existing customers can generate repeat sales. Again, frequent email marketing keeps your company in front of customers.
  • Add 30% to an average order – Up-sell and cross-sell products and services. For example, a customer orders a necklace from your jewelry store, follow up with an email about earrings that match the necklace.
  • Save money – Even after design, testing and sending the email, you will save 78% over traditional mailers.
  • Save the environment – Trees don’t need to die for email marketing.

Call 480-874-4379 or contact us for more information and plan pricing.

How to an Show Excerpt with a Read More Link in WordPress

If you don’t want to have to use the more quicktag for every post, you can automate WordPress to display just the excerpt of a post on your home page, category page and archive page. This will also add a read more link to the rest of the article.

Find the below code in your archive.php, category.php and index.php template pages.

<?php the_content(__('Read more'));?><div style="clear:both;"></div>

Replace with:

<?php the_excerpt(); ?><span class="read_more"><a href="<?php the_permalink(); ?>">[ Read More &raquo; ]</a></span>

It is that simple!

How to Add a Second Sidebar to Your WordPress Theme

This tutorial will cover how to add a second sidebar to your WordPress theme. This is very useful when you have a 3 column layout.

WordPress 2.5 introduced the name parameter to the include tag get_sidebar().

We are going to add a widgetized left sidebar and a widgetized right sidebar to a 3 column layout.

Step 1: Create 2 files, named sidebar.php and sidebar-right.php.

Code for sidebar.php

<?php
/**
Template Name: Sidebar
 */
?>
<div id="sidebar">
<ul>
<?php 	/* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php endif; ?>
</ul>
</div>

The id of the sidebar can be anything you would like. The code between the php tags should not be changed.

Code for sidebar-right.php

<?php
/**
Template Name: Sidebar Right
 */
?>
<div id="sidebar-right">
<ul>
<?php 	/* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Sidebar Right') ) : ?>
<?php endif; ?>
</ul>
</div>

The id of the sidebar can be anything you would like. The code between the php tags should not be changed.

Step 2: Add the following to your template files where you would like your sidebars to display in your layout. The most template files are archive.php, category.php, index.php, page.php and single.php. The WordPress Codex has a tutorial on template pages and template hierarchy.

<?php get_sidebar(); ?>
<?php get_sidebar('right'); ?>

Step 3: Add this to your functions.php page.

<?php
if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
        'after_title' => '</h2>',
    ));

    register_sidebar(array('name'=>'sidebar-right'
    ));

Below is what it should look like in your WordPress admin panel.
Widget Admin