WordPress shortcode/cart count/ current page URL/check user login

Below function has WordPress shortcode/cart count/ current page URL/checking user is logged-in or logged-out
cartlogin function will return the cart and different message for logged-in and logged-out user.

function cartlogin_func( $atts ) {

global $current_user;

$div .= ‘<a href=”/cart/” target=”_self” rel=”noopener noreferrer” aria-label=”link to /wishlist/”><i class=”fas fa-cart-plus” aria-hidden=”true”><b>’.WC()-&gt;cart-&gt;get_cart_contents_count() .'</b></i></a>’;

if ($current_user-&gt;ID == ”) {
global $wp;
$rd = home_url( add_query_arg( array(), $wp-&gt;request ) );
$div .= ‘<a class=”loginre” title=”Quick Login/Register” href=”#”>Login/Register</a></pre>
<div class=”sociallogin nsl-container nsl-container-block” data-align=”left”>
<div class=”nsl-container-buttons”><a href=”/wp-login.php?loginSocial=facebook&amp;redirect=’.$rd.'” rel=”nofollow” aria-label=”Continue with &lt;b&gt;Facebook&lt;/b&gt;” data-plugin=”nsl” data-action=”connect” data-provider=”facebook” data-popupwidth=”475″ data-popupheight=”175″><span class=”nsl-button nsl-button-default nsl-button-facebook”><span class=”nsl-button-label-container”>Continue with <b>Facebook</b></span></span></a><a href=”/wp-login.php?loginSocial=google&amp;redirect=’.$rd.'” rel=”nofollow” aria-label=”Continue with &lt;b&gt;Google&lt;/b&gt;” data-plugin=”nsl” data-action=”connect” data-provider=”google” data-popupwidth=”600″ data-popupheight=”600″><span class=”nsl-button nsl-button-default nsl-button-google” data-skin=”uniform”><span class=”nsl-button-label-container”>Continue with <b>Google</b></span></span></a><a href=”/wp-login.php?loginSocial=twitter&amp;redirect=’.$rd.'” rel=”nofollow” aria-label=”Continue with &lt;b&gt;Twitter&lt;/b&gt;” data-plugin=”nsl” data-action=”connect” data-provider=”twitter” data-popupwidth=”600″ data-popupheight=”600″><span class=”nsl-button nsl-button-default nsl-button-twitter” style=”background-color: #4ab3f4;”><span class=”nsl-button-label-container”>Continue with <b>Twitter</b></span></span></a></div>
$div .= ‘<span style=”float: right;”>Welcome <a href=”https://hotandcoldoutlet.com.au/my-account/”>’.$current_user->user_firstname.'</a>  </span>’;
return $div;

add_shortcode( ‘cartlogin’, ‘cartlogin_func’ );

Woocommerce update price of product by particular category or tag

WordPress product table has relation with 3 tables post, postmeta, term_relationships.

Once we need to update price of particular category or tag products this will take days of time as per the product count but using mysql query we can easily achieve this:

    `meta_value` = meta_value + (meta_value * (2.64 / 100))
    meta_key = '_price' 
    AND `post_id` IN (
            `object_id` AS product_id 
            term_taxonomy_id = 827
            AND `object_id` IN (
                    `post_type` = 'product' 
                    AND `post_status` = 'publish' 
                    AND `ID` = `object_id`

Optimise WordPress

Below is quick methods using that we can optimise wordpress:

Need to add this code top of the header.php file

<?php function callback($buffer)
$buffer = str_replace(“type=’text/javascript'”, “”, $buffer);
$buffer = str_replace(‘type=”text/javascript”‘, ”, $buffer);
$buffer = str_replace(“type=’text/css'”, “”, $buffer);
return ($buffer);

ob_start(“callback”); ?>

Add at the bottom of footer.php file <?php ob_end_flush(); ?>

optimise wordpress

Remove emoj icons from wordpress
function disable_wp_emojicons() {

remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );

//Remove filter TinyMCE emojis
add_filter( ‘tiny_mce_plugins’, ‘disable_emojicons_tinymce’ );

add_action( ‘init’, ‘disable_wp_emojicons’ );

function disable_emojicons_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( ‘wpemoji’ ) );
} else {
return array();

1. Update new version of WP
2. Add images on CDN
3. optimise CSS, HTML, JS, DB
4. Optimise and cache all pages
5. Improve site performance and speed.
6. Will remove unnecessary JS and CSS and WP functions for optimisation
7. server beverage
8. Clean up your code wp-config file setting

define( 'WP_POST_REVISIONS', 3 );

Enable Multisite / Network Ability

define( 'WP_ALLOW_MULTISITE', true );

Redirect Nonexistent Blogs

define( 'NOBLOGREDIRECT', 'http://example.com' );


define( 'WP_DEBUG', true );
define( 'SCRIPT_DEBUG', true );