Tuesday, May 22, 2012

How to remove 'Leave a Reply' from Twenty Eleven' pages when it WON'T go away


Sometimes, no matter how many times you use a Wordpress theme they way it wants to be used, it doesn't work the way you need it to. The obvious solution to remove the 'Leave a Comment' or 'Leave a Reply' section on posts and pages when using Twenty Eleven (or Twenty Ten, if you're stubborn) is to uncheck 'Allow people to leave new comments' on Settings>Discussions - but alas, that doesn't work. Or, I guess it does, but not the way any sane person would want it to (the 'Leave a Reply' window remains displayed, you just aren't allowed to use it). 
You can also try going to Pages>All Pages and clicking Quick Edit on the page that is making you crazy, and unchecking the 'Allow Comments' box, but chances are you will just start tearing out more of your hair - because that won't make the *%$@# form go away either. 
Never fear - I found the solution!
If you are comfortable editing theme files, go into page.php (where your theme uses the comment function) and remove or comment out the function. It may look something like this:
<?php comments_template(); ?>
To comment it out (make it not have any effect on your site) put two slashes in front of it, like this:
<?php // comments_template(); ?>
Make sure you backup your theme before making any changes!!

Thursday, May 10, 2012

WP-E-commerce - How to hide 'Add to Cart' button if your user is not logged in

I have been searching and searching for WEEKS on how to do this, and now that I figured it out, it seems so obvious! I thought I would post the answer here for all of you that are as stubborn as me and are still trying:

In both wp-content>plugins>wp-e-commerce>wpsc-theme>wpsc-products_page.php and wp-content>plugins>wp-e-commerce>wpsc-theme>wpsc-single_product.php, change this line:
<?php if((get_option('hide_addtocart_button') == 0) && (get_option('addtocart_or_buynow') !='1')) : ?>
to this:
<?php if((get_option('hide_addtocart_button') == 0) && (is_user_logged_in()) && (get_option('addtocart_or_buynow') !='1')) : ?>
Basically, saying if the user is logged in, show the 'add to cart' button, otherwise, don't.

Ah! Now don't we all feel better?