Sunday, 14 November 2021

PHONE NUMBER OR EMAIL NOT REQUIRED

 // For billing email and phone - Make them not required

add_filter( 'woocommerce_billing_fields', 'filter_billing_fields', 20, 1 );
function filter_billing_fields( $billing_fields ) {
    // Only on checkout page
    if( ! is_checkout() ) return $billing_fields;

    $billing_fields['billing_phone']['required'] = false;
    $billing_fields['billing_email']['required'] = false;
    return $billing_fields;
}

Sunday, 7 November 2021

WP Snippet

 To add code to your header, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
?>
PASTE HEADER CODE HERE
<?php
};

To add code to your footer, use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_footer', 'your_function_name');
function your_function_name(){
?>
PASTE FOOTER CODE HERE
<?php
};

For each snippet, make sure to change:

  • The comment description (helpful when you need to remember what a code snippet does a year later)
  • The your_function_name placeholder (both instances)
  • The PASTE X CODE HERE placeholder

Step 2: Add Code Snippets to functions.php File in Child Theme

Once you have the relevant code snippet(s) ready, you need to add them to the functions.php file of your child theme. You can either edit this file by connecting to your site via FTP. Or, you can go to Appearance → Editor and select the functions.php file. Then, paste your code at the end of the file:

Add code to functions.php file

Add code to functions.php file

Make sure to save your changes and you’re done!

If you want more control over where your header or footer code snippets show up, you can use if statements to only add the code to specific pages on your WordPress site.

For example, to only add code snippets to the header or footer of your homepage, you could use:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
if(is_front_page()) {  ?>
PASTE HEADER CODE HERE
<?php  }
};

Another option is to only add the code snippets to specific posts or pages. To do that, you can use this code snippet:

/* Describe what the code snippet does so you can remember later on */
add_action('wp_head', 'your_function_name');
function your_function_name(){
if(is_single(73790)) {  ?>
PASTE HEADER CODE HERE
<?php  }
};

Make sure to replace the example number – 73790 – with the actual ID of the post or page you want to add the code snippets to.

email mailto: pretext

 <a href="mailto:designoutsourced.com+info@gmail.com?subject=Maklumat%20lanjut%20pakej&body=Hai,%20saya%20berminat%20tahu%20lebi...