Thursday, October 25, 2012

Wordpress and Thesis Code Solutions Used for an E-commerce Site

Multiple Custom Sidebars in Thesis Using Filters
(Get custom sidebars in Thesis without custom page templates.)
Using a four part approach, of which three parts are included on this DIY Themes tutorial and the final part of which was gleaned from this well written article about Sidebars in Wordpress, we were able to create a total of four custom sidebars that all work brilliantly.  One of the main keys to getting all of them to work correctly was the tip by Justin Tadlock that each sidebar must have a unique ID.  The name of the sidebar does not really matter, because without unique ID's Wordpress will assign them automatically and cause chaos.  We placed widgets in multiple sidebars before assigning unique ID's and they were going haywire.

Fix "Fatal Error: Allowed Memory Size" problems
WordPress Error Fix(?): Increase PHP Memory for cache.php : Perishable Press
The second method in this tutorial using htaccess started generating errors on our server, so be aware if that one does not work for you.

After adding in the memory limit fixes to bypass the error, the cache in your local browser may be a bit screwed up, so you'll want to clear your browser cache if you notice anything is not working correctly on your site or if any panels in the Wordpress Admin area.  We had a NextGen gallery slideshow stop working on our homepage and also had some styling disappear from our Ubermenu navigation menu.  As soon as we cleared our Firefox/Chrome browser cache, everything was back to normal.

Remove "0 Comments" Thesis Section from Wordpress E-Commerce Store Pages
Display shopping cart on specific pages only? - GetShopped.org
The Thesis theme was automatically adding the "0 Comments" section to any of our WP E-commerce product category pages that had a category image.  WPEC products and category pages do not have a custom post type, but they do have a custom taxonomy (as of version 3.8.8.3).  The conditional tags below will allow you to remove any Thesis elements and also create custom sidebars that only apply to your store pages.

is_tax( 'wpsc_product_category' )
is_singular( 'wpsc-product' )

Put the following code in your custom_fuctions.php file

function my_comments_link() {
  if (!is_single() && !is_page() && !is_tax( 'wpsc_product_category' )) {
    echo '<p class="to_comments"><a href="';
    the_permalink();
    echo '#comments" rel="nofollow">';
    comments_number(__('Post a comment', 'thesis'), __('<span>1</span> comment', 'thesis'), __('<span>%</span> comments', 'thesis'));
    echo '</a></p>';
  }
}

remove_action('thesis_hook_after_post', 'thesis_comments_link');
add_action('thesis_hook_after_post', 'my_comments_link');



Create a Three or Four Column Widgetized Footer in Thesis
This tutorial straight from the official Thesis source provided most of the code we needed to create a four column widgetized "fat" footer on our site.  We made a few important changes to make everything work smoothly with our other custom sidebars.  The most important style change was to change the overall CSS width from 33% to 25% since we used four columns instead of three.  While registering new sidebars, we added a unique ID for each, since this is a best coding practice.


Custom Sidebar Background Colors for a Set of Specific Pages in Thesis
Using the third code section in this official DIYThemes tutorial, we were able to create our own BODY class and apply it to a specific set of pages with a conditional tag.  We used a page array, but you can use whatever conditional tags are needed to target specific pages/posts/etc.

in custom_functions.php:

// Add a class for Gallery pages styling
function gallery_styles($classes) {
    if (is_page(array(6, 160, 162, 699, 4521, 165, 169, 171, 173, 175, 703, 50, 53, 143, 241, 243, 245, 254, 247)) ) {
        $classes[] = 'gallery_custom_colors';
     }
    return $classes;
}
add_filter('thesis_body_classes', 'gallery_styles');


in custom.css:

.gallery_custom_colors #content {
    background-color: #252121;
    color: #888888;
}

.gallery_custom_colors #content_box {
    background-color: #8f8889;
}

.gallery_custom_colors h1 {
    color: #888888;
}


Fixed Product Category Pages Not Displaying the First Product Title in Wordpress E-Commerce
Issue 681 - wp-e-commerce - wpsc-products_page.php not displaying first product title?
We used the code posted in comment #5 from March 22, 2012 to fix this issue on our site.  See the next section below.  We also had to remove the Thesis headline area, because it was listing the name of a product and not the name of the category. (See the next link below for more info.)

Fixed the Category Title Not Displaying on Wordpress E-Commerce Store Category Pages


Remove the Thesis Headline Area on Wordpress E-Commerce Store Category Pages
thesis_show_headline_area (DIYThemes)
We used this code with a conditional tag modification to remove the headline area only on the store pages.

To target only Wordpress E-Commerce Store category pages, use this conditional tag:
is_tax( 'wpsc_product_category' )

Remove the Thesis 'Previous and Next' Links
Move Previous and Next Links (DIYThemes)


Add some text or content above your Thesis header
Coming Soon

Listing Recent Posts from a Specific Category with a Shortcode
Mastering WordPress Shortcodes | Smashing WordPress
We used #5 Get posts from WordPress Database with a Shortcode.  The client wanted to create an article page that would automatically list recent posts from a specific category.  I made the shortcode a friendly name [adventure_posts] so everyone working in the Wordpress dashboard would know what it does.

No comments:

Post a Comment

Only comments in English will be considered. Thank you!