Revised Fake Grid View

Updated April 19th 2009

If you are using the latest version of the WordPress Shopping Cart plugin, version 3.12.6, please read my latest post on the subject:
“Revised File for Fake Grid View”
The following post is helpful but the file to be downloaded was written for version 3.6.7.

I use wpsc when I mean WordPress Shopping Cart.
Here is a re write of an earlier post on “faking” Grid View(for wordpress shopping cart plugin).
My earlier post did not take into account, beyond styling the page with CSS, the functions in homepage_products_functions.php and how the output of this file varies from the real grid view product display.
So if you have purchased Grid View you should be able to use the Cart Icon button in the Post or Page editor to insert a wpsc category into a Post or Page and have it display just like Grid View,right? I thought so. But it doesn’t work that way.Inserting a single category into a page results in a page that looks a lot like grid view but acts quite differently.

Some key differences between using homepage_products and the grid view
Inserting a wpsc category into a Page(shortcode is for homepage_products) displays a thumbnail gallery of all products from one category and their product titles. If you use “Full” your page will not look like Grid View. If you don’t select Full you will get close to faking Grid View ( if you have the correct CSS to do so). But a Fake Grid View page has one little problem:the thumbnail image does not link to the single product display page(like in Grid View).Instead,it links to the thumbnail image.Which means a thumbnail image will pop up where a full size image should.
Continue reading Revised Fake Grid View

Making the change from HTML pages to WordPress

This article is for Web designers who want to switch a website that was built using dot html pages to WordPress. It is a relative snap to transfer any website, large or small, to WordPress.
The benefits of using WordPress instead of static pages are numerous. Concerns over losing ranking and generating 404’s are reasonable ones but they are concerns I am going to address in the following steps.

First Step:Get the latest version of WordPress &Install WordPress into it’s own directory.
Installing WordPress in it’s own directory allows you to work on the new design behind the scenes.If you don’t want to do that you can of course work on your own server and then upload the theme to your client’s WP installation. I like to work within the client environment so I can get to know any problems or quirks on the server before going live. Not all servers are created equal. Go to Settings>> Privacy and block search engines so that the work in progress does not get indexed if working on the client server. Or create a robots.txt file if one doesn’t already exist and type in
Disallow
/wordpress
Remember to remove this directive when going live.

Next Step:Making New Pages Out Of Old Pages.
An easy but time consuming step is copying and pasting the old html page content into the new WordPress pages and re instituting page order using the Page Order option
in the WordPress Page Editor. Number the old html pages and assign page order accordingly. If you have only 5 old pages to be carried over, you’ll be done very quickly. Designers handling the redesign of a much larger site with Parent and Child pages will have extra steps-especially if they need to build a drop down menu out of pages with child pages.Never fear:there are plugins that create dropdown menus for you. The one from We Eat Bricks looks the most promising

What the Blank is index.php?p=4? About-Us.htm looked so much better!
Using the permalink structure /%category%/% postname%
http://www.website.com/about-us.htm becomes http://www.website.com/about-us.
You choose this option in Settings>>Permalinks and find the Custom option. Paste what is in bold type into the field named Custom.

I heard recently that the fuss over pretty permalinks might have gotten a little overheated and that engines can and do index these kind of urls. But you will no doubt agree www.website.com/about-us looks a lot nicer than www.website.com/?p=4.

SEO Stuff
In my experience of redesigning websites, most had no SEO when I got my hands on them anyway but why continue on a bad path? As a web designer you might feel you should not have to worry about aspects that seem to fall more into the Marketing arena, right? Maybe. But many times the reason a client wants a redesign in the first place has nothing to do with how the site looks and more to do with such performance issues as: they aren’t getting as much traffic as they want or making many sales or landing as high in the SERPS as they would like. Fair or unfair they will probably blame you if their site doesn’t get climb higher in the SERPS after you deliver the new site. You should tell them that the more unique their content/product/service the more results they will see and that it will take time to see these results,too.Please do not make any unrealistic guarantees and make sure they are aware that the more often they update their sites the more they will be crawled.

There is one page that should not be carried over into the new design:the Splash or Intro Page.The Internet should be for offering information but because Splash Pages have very little information to offer, search engines tend to see this one page as the whole site and go away without indexing any links or real information about the website. I could go one step further and blame low performance on the Splash Page alone.The index page needs to be clean and uncluttered,true but don’t repeat the mistake of choosing style over substance.If you take a look at successful websites you will see that most put a lot of information on the index page.

All in One SEO
because WordPress doesn’t supply an option to create meta descriptions install the All in One SEO plugin.After you’ve activated this plugin each page will have a new All In One Seo option when you edit them.

Writing Meta Descriptions
If you are lucky the previous designer took care to create good meta descriptions for each page they made and then you can just paste this into the All In One SEO description field box.But if not you’re going to have to read the page content and pluck out of it a 160 character long description. 160 characters is believed to be the length after which search engines stop reading.

Using Keywords
It is argued over and over that Search Engines ignore keywords. If writing a Post instead of a Page you can use Tags and the All In One SEO plugin will use those tags as keywords.You shouldn’t worry overly about meta keywords.

Unique Page Titles
Page Titles need to be unique whether an it’s for an archive or a category or a Page page.
For Pages the title issue is taken care of when you publish the new page.Out of the box, most WordPress theme’s way of handling the title section needs a bit of help. So you should also install this code in the header.php file of the theme you are using:
[php]<title><?php

// Page or Single Post
if ( is_page() or is_single() ) {
the_title();

// Category Archive
} elseif ( is_category() ) {
printf( __(‘Archive for &lsquo;%s&rsquo;’), single_cat_title(”, false) );

// Tag Archive
} elseif ( function_exists(‘is_tag’) and function_exists(‘single_tag_title’) and is_tag() ) {
printf( __(‘Tag Archive for &lsquo;%s&rsquo;’), single_tag_title(”, false) );

// General Archive
} elseif ( is_archive() ) {
printf( __(‘%s Archive’), wp_title(”, false) );

// Search Results
} elseif ( is_search() ) {
printf( __(‘Search Results for &lsquo;%s&rsquo;’), get_query_var(‘s’) );
}

// Insert separator for the titles above
if ( !is_home() and !is_404() ) {
_e(‘ at ‘);
}

// Finally the blog name
bloginfo(‘name’);

?></title>[/php]

That will sort out Archives,Tags,Categories titles which you can also tell the engines not to index in Settings>> All In One SEO. Download the plain text file here:seotitles
I edited the file recently because of some confusion of mine over some very similar html characters:
‘ ’
« »
[html]&lsquo; &rsquo;[/html]
[html]&laquo; &raquo;[/html]
The file is using lsquo and rsquo….

Going Live
You have all your pages set up and the design is finished and you are ready to go live, what next?
Read this article on installing WordPress in it’s own directory.If you’ve followed all the steps your new WordPress site should appear when you go to http://www.website.com/. If your old index.html page still pops up then you have a little more work to do. Paste this into main .htaccess:
DirectoryIndex index.php index.html
Placing index.php first takes care of that little problem.

Redirecting Traffic 301
Gather a list of all the old site’s links.
http://www.website.com/about-us.htm
http://www.website.com/contact.htm
http://www.website.com/projects.htm

Find the top level .htaccess in your website root and open it up for editing with a plain text editor like NotePad or Textwrangler.If you use a Mac you will have to rename the file to htaccess.txt so that you can save it to reupload it. Macs hide . files.

Redirect 301 /about-us.htm http://www.website.com/about-us
Redirect 301 /contact.htm http://www.website.com/contact
Redirect 301 /projects.htm http://www.website.com/projects
Repeat this until you have covered every last page from the old website’s linkage structure.
Save the file and upload it back to the top level directory.

Last is to turn off blocking search engines in Settings>>Privacy.

Important Last Steps You’ll Be Glad You Took:
Add www.website.com to Google and Create and Submit a Sitemap in Google Webmaster Tools. You’ll also want to make good use of Google Analytics.

WordPress as a CMS:Too Complicated for Clients?

It depends.
I’ve noticed that my clients are not big on selecting categories when they write new posts. And it is the rare client that pays any attention to Tags.But for the average client I would not recommend setting up a site that needs Custom Fields. Categories, yes. Categories are far more intuitive and a much easier concept to grasp.If your client is advanced enough to use Custom Fields chances are they don’t really need you at all!

But for the average client,if I have set up a site that depends on the correct selection of categories before publishing, I have to teach them that they must select the right category when writing a new post.If they get it (and most of my clients do get) it works.
Using WordPress as a blog does not depend on picking the right category. Because all posts get looped by index.php whether they are in category 3 or category 1003. But maintaining a site that is using WordPress as a CMS and a blog requires playing by some simple rules.

WP as a CMS, 2 Blogs in One
Here is an example of WordPress as a CMS that might be considered “too complicated” for some clients to upkeep. This site has a home page template using one version of index.php and a simple custom query to show only Featured posts. While another template loops only the Events posts. For this site I kept it very simple by creating only 2 categories. By keeping it this simple and knowing that my average client does not tend to create new categories just for kicks fingers crossed, this will be an easy site to maintain.

How to get 2 “blogs” in one. One “blog” on the frontpage that shows only one category and another “blog” that will use one master category to show all the other posts.
I left Reading settings as “Frontpage displays: your latest posts”. I wanted those latest posts to be from only one category. And then I wanted to exclude these posts from the other “blog” and vice versa. The question was use a category template or use a custom query in a template? I’ve used both and it’s my opinion that category templates are the better way to go.

Using a custom query
Trying to get posts in a template from one or 2 categories using a custom query breaks the next post navigation. This means you either have to set your Reading settings to show 100 posts or to use the showposts=100 in the custom query. It’s not that elegant. And I always felt it was a broken but working kind of way to use WP. Meaning it sort of does what you want but not really.

Using a category template
To use a category template all you have to do is copy your index.php and rename it category-1.php.
In this project’s case, category 1 is the Events category which is the second blog and is going to be used as a “real” blog. Upload category-1.php to your theme folder. That is all you have to do.How does WP know to use this file? When it comes to categories WP is set up to look for a category template first.

How to keep posts belonging to category 1 out of the front page?
Paste this in the template you are using for the Featured posts to keep category 1 posts out of the front page: [php]<?php query_posts($query_string . "&cat=3,-1"); ?>[/php]

code explanation
Category 3 is the Featured Posts category that I do want on the front page. Category 1 has a minus before it because I do not want posts from the Events (category 1) showing upon the home page.The template for the Featured posts is the main index.php file.The template for the Events Posts is a copy of the main index.php file.


How to keep posts belonging to category 3 out of the Blog?

Because WordPress will show posts from a specific category if you use a category template only posts from the Events category will show up on the blog pages. So you don’t have to do anything extra to this template.

Navigation
If Categories are the backbone of WordPress then Navigation is the backbone of your website.
(Many ready made themes already provide this in header.php ) but are set up for WordPress to be used as a blog so they probably include a link to Home and then add in the code below as well. But if you write a page called Home “Home” will then show up twice in your menu–which you probably don’t want.I find it is easier to include or exclude pages from my top navigation rather than hand coding in a link to pages. Here is how to include or exclude:
[php]<ul id="nav"><?php wp_list_pages(‘sort_column=menu_order&depth=1&exclude=12,16,18&title_li=’);?></ul>[/php]

code explanation
What this does is build a navigation menu of your pages while excluding pages with ids 12,16 and 18.
Excluding pages from the top menu is easy– all you have to know is the id number of the page you would like to exclude.This code will not show child pages.*

If you need a category title to show in your navigation you can do this:
[php]<ul id="nav"><?php wp_list_pages(‘sort_column=menu_order&depth=1&exclude=12,16,18&title_li=’);?><?php wp_list_categories(‘sort_column=name&title_li=&exclude=3’); ?></ul>[/php]

code explanation
Now your menu will show all your pages and at the end will show the Events category but will exclude the Featured category.

This does have it’s drawbacks.There is a limit to how many tabs you can have in a horizontal menu without going 2 tier. If my clients don’t add new categories doesn’t mean your client’s won’t.

So another way to insert a tab for the Events category would be to do this:
[php]<ul id="nav"><?php wp_list_pages(‘sort_column=menu_order&depth=1&exclude=12,16,18&title_li=’);?><li><a href=" <?php echo get_category_link($category_id=1);?> ">Events</a></li>
</ul>[/php]

Of course this has it’s drawbacks, too. It will make sure your menu doesn’t get overcrowded with category tabs but it will only create a tab for the Events category. If there are child categories of the Events category they will not be displayed in the list of posts. (**Not True!-Yay**)Still, this might be the best way to go. You can show other categories in a sidebar or use a query to show the child categories in the Events category template. Or you can use Yet Another Related Posts plugin (YAPP) or similar that creates a list of related posts using parameters.

Any site you hand off is going to require some attention from you.If you know you won’t be able to give your time try to set up the website accordingly. Don’t expect a client to get it right away. Be prepared to repeat instructions.

*This plugin will create a dropdown on any page with child pages:Multi Level Navigation .It should be used to replace your current menu so pay attention to the Advanced options.You will have to play with the css a bit but they also provide a css generator.

Invalid argument foreach() error in WordPress Shopping Cart Plugin

my cart iconFor the longest time I held off upgrading any of my client’s stores using WP-Shopping Cart plugin because on my test install of WP I could not get RC1 3.6.8 to work.But it really bothers me not to use the latest version of something so on one client site I did the upgrade and tested it out.I got the same exact errors I got on my test install after trying to checkout/submit and have the payment sent to PayPal.

The old invalid argument foreach() error.

Going to the forum I did not see a way to fix this probably because everyone has different causes for this error? I’m not really sure but there should be definite documentation on how to get rid of so people can have a working cart.

Error Log Messages
This error:
WordPress database error Unknown column ‘files’ in ‘field list’ for query INSERT INTO `wp_cart_contents` ( `prodid` , `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `donation`, `no_shipping`, `files` ) VALUES (’18’, ’75’,’64.50′,’0′, ‘0’,’1′, ‘0’, ‘1’, ”) made by nzshpcrt_submit_checkout

Led to this error:

PHP Warning: Invalid argument supplied for foreach() in /xxx/web10/xxxx/pow.xxxl/htdocs/site/wp-content/plugins/wp-shopping-cart/merchants/paypal_multiple.php on line 82

And this all led to the cart being empty and the logs printing the price as 0.00. If the cart can’t put the order into the wp_cart_contents table it can’t process the order. Not being able to fill in the info leads to a PHP error.

Let’s look at this message again:
WordPress database error Unknown column ‘files’ in ‘field list’ for query INSERT INTO `wp_cart_contents` ( `prodid` , `purchaseid`, `price`, `pnp`, `gst`, `quantity`, `donation`, `no_shipping`, `files` ) VALUES (’18’, ’75’,’64.50′,’0′, ‘0’,’1′, ‘0’, ‘1’, ”) made by nzshpcrt_submit_checkout

Everyone of those fields has to be in the wp_cart_contents table in your WP database.If your cart works perfectly all the way up to trying to test if orders can be processed- chances are when you upgraded a field or 2 even were not created.This can happen to WP upgrades as well.It is not a failing of the cart plugin.The fact that some people have no problem upgrading anything speaks to this.

The wp_cart_contents table.
——————-Type——– –Collation — —-Attributes— — — —Null—- — Default
purchaseid—–bigint(20) ——– —– — -UNSIGNED— – — — -No—— ——0
prodid—— – bigint(20) —– —— — — -UNSIGNED– — — –No—— ——0

——————Type———- —–Collation——- —-Attributes— ——Null——-Default
price——-varchar(128)——–latin1_swedish_ci ————– ——–No———-0
pnp———varchar(128)——–latin1_swedish_ci ——– — —– —-No———-0
gst ———varchar(128)——–latin1_swedish_ci ——- ——— – — No———0
quantity– –int(10)———————————— -UNSIGNED— — No ———-0
donation– -varchar(1) ——— latin1_swedish_ci—- —— — —— No ———0
no_shipping – varchar(1)——–latin1_swedish_ci ——— —- — — – No ———- 0
files ——- —text—————-latin1_swedish_ci——— —— — — No ———-

I know it isn’t really a table but it will have to do.

Fixing It
First check your error logs. It’s good to check your error logs the very first sign of trouble. If you can see the same kind of errors that I printed here you are having the same problem I was: field files was not added to the wp_cart_contents table when I upgraded. How pesky.

1st, log into your control panel find Manage Mysql and when you are in the manage mysql area, click on Administer for your WordPress database.

When you are in, look in the left side panel for wp_cart_contents. Click on it.

Please check to see if a “files” line has been added after the no_shipping line in wp_cart_contents.
If not, don’t be scared. It is easy-peasy to add a field to a database table.If the field called files is already there your problem is being caused by something else.Check the table for missing fields you can use my ugly “graph” up above.There should be 9 fields.If anyone of these fields is missing from the table you are going to get the invalid argument foreach() error.

If the field for “files” was not added – no_shipping will be the last field in this table.It was for me.

Look for this option it’s usually underneath the bottom of the table (my host uses phpMyAdmin some other managers will be set up differently).

Add 1 field(s) At End of Table.

Leave the 1 field to be added. Leave the radio button for At End of Table selected.

Then look for the go button-Click go.

In the Field text box, type files and use all use lowercase.

In VARCHAR dropdown list, select TEXT.

Leave everything else alone and click the save button.It’s very important to save it or the field will not get added.

Test it Out!
You should now be able to add an item to the cart and checkout and send the payment to PayPal with no more errors and blank orders in the purchase logs,

if all your checkout and payment settings in the admin for the plugin are correct and there aren’t any other issues with the plugin besides the ones I have written about.