Friday, June 28, 2013

How to add menu to footere in wordpress?

The following single line code add in footer where you want to show menu bar.


Syantax:

<?php wp_nav_menu(array('menu' => 'name')); ?>
                          where name = Menu slug name.

Example:

<?php wp_nav_menu(array('menu' => 'my-custom-menu')); ?>

Wednesday, June 26, 2013

How to change Woocommerce products per page?

By adding the following one line code to your functions.php file, we will change the products per page in Woocommerce.
Now i would like to display 12 products in the place of regular 10 products.


add_filter('loop_shop_per_page',create_function('$cols','return 12;'),20);

Friday, June 21, 2013

Show cart contents / total at WooCommerce header in Wordpress?

Add the following bit of code to your header file exactly where you want to display the cart total items value.

<?php global $woocommerce; ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?>
</a>

<!---Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)---->

<?php
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>

<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?>
</a>

<?php
$fragments['a.cart-contents'] = ob_get_clean();
return $fragments;
}
?>

Keep Smiling.
Naresh.

Thursday, June 20, 2013

How to add WooCommerce short codes in Wordpress Template files?

By using do_shortcode() function we can add the WooCommerce shortcode 
to the template files.
Syntax:
<?php echo do_shortcode( 'ShortCode' ); ?>
Example:
<?php echo do_shortcode( '[fblike]' ); ?>


Keep Smiling

Naresh.

How to display welcome note in Wordpress along with user name?

The following piece of code full fill your requirement.

<?php
global $current_user;
get_currentuserinfo();
if(isset($current_user->user_login))
{
    $name=$current_user->user_login;
    echo 'Welcome '.ucfirst($name);
}
else
{

}
?>

......................
Keep Smilimg.