Categories
ecommerce Storefront WooCommerce wordpress

WooCommerce Storefront Child Theme: Remove Sidebar @ Single Product Page

Hide the sidebar on product pages of Woocommerce Storefront child theme. The following snippet disables the sidebar with no additional CSS required, whilst still making the product page content area 100% wide.

/**
 * Disable sidebar on product pages in Storefront.
 *
 * @param bool $is_active_sidebar
 * @param int|string $index
 *
 * @return bool
 */
function product_remove_sidebar( $is_active_sidebar, $index ) {
	if( $index !== "sidebar-1" ) {
		return $is_active_sidebar;
	}
if( ! is_product() ) {
return $is_active_sidebar;
}

return false;
}

add_filter( 'is_active_sidebar', product_remove_sidebar', 10, 2 );

 

code to the functions.php file in your Storefront child theme.

Categories
cms multisite Nginx wordpress

wordpress multisite too many server redirects nginx conf

too many server redirects.
 
#wordpress #multisite #wordpressmultisite .conf #nginx #bookmark
 
server {
server_name example.com *.example.com ;
 
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
 
root /var/www/example.com/htdocs;
index index.php;
 
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
 
location / {
try_files $uri $uri/ /index.php?$args ;
}
 
location ~ \.php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
 
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
 
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Categories
ecommerce WooCommerce wordpress

woocommerce redirect to a custom page after logging out

// redirects for login / logout
add_filter(‘woocommerce_login_redirect’, ‘login_redirect’);

function login_redirect($redirect_to) {

return home_url();
}

add_action(‘wp_logout’,’logout_redirect’);

function logout_redirect(){

wp_redirect( home_url() );

exit();
}

Categories
ecommerce WooCommerce wordpress

WooCommerce: always showing add-to-cart button even before variation is selected

add_action( ‘woocommerce_before_add_to_cart_button’, function(){
// start output buffering
ob_start();
} );

add_action( ‘woocommerce_before_single_variation’, function(){
// end output buffering
ob_end_clean();
// output custom div
echo ‘

‘;
} );

http://stackoverflow.com/questions/29377643/woocommerce-always-showing-add-to-cart-button-even-before-variation-is-selected

Categories
ecommerce WooCommerce wordpress

woocommerce Change Related Product Text

gettext – The Most Useful Filter in WordPress http://speakinginbytes.com/2013/10/gettext-filter-wordpress/

/**
* Change text strings
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case ‘Related Products’ :
$translated_text = __( ‘You may also like these’, ‘woocommerce’ );
break;
}
return $translated_text;
}
add_filter( ‘gettext’, ‘my_text_strings’, 20, 3 );

Categories
multisite wordpress

wordpress multisite admin login loop

in wp-config file, insert this define line – define(‘COOKIE_DOMAIN’, ‘.yourdomain.com’);