Horje

Tips (Total 2)


# Tips-1) How to Add Custom User Profile Fields

Place the code below into your functions.php file to add custom user profile fields. Edit or add lines as you see fit.

Add Custom User Profile Fields

Remember not to remove the line: return $contactmethods; otherwise this won't work.

Example: PHP
// CUSTOM USER PROFILE FIELDS
   function my_custom_userfields( $contactmethods ) {

    // ADD CONTACT CUSTOM FIELDS
    $contactmethods['contact_phone_office']     = 'Office Phone';
    $contactmethods['contact_phone_mobile']     = 'Mobile Phone';
    $contactmethods['contact_office_fax']       = 'Office Fax';

    // ADD ADDRESS CUSTOM FIELDS
    $contactmethods['address_line_1']       = 'Address Line 1';
    $contactmethods['address_line_2']       = 'Address Line 2 (optional)';
    $contactmethods['address_city']         = 'City';
    $contactmethods['address_state']        = 'State';
    $contactmethods['address_zipcode']      = 'Zipcode';
    return $contactmethods;
   }
   add_filter('user_contactmethods','my_custom_userfields',10,1);

To display custom fields you can use one of the two methods listed below.

Option - 1

Use Following codes to themes
Example: PHP
the_author_meta('facebook', $current_author->ID)

Option - 2

Use Following codes to themes
Example: PHP
<?php $current_author = get_userdata(get_query_var('author')); ?>
<p><a href="<?php echo esc_url($current_author->contact_phone_office);?>" title="office_phone"> Office Phone</a></p>

# Tips-2) How to limit WooCommerce Title Lenght?

Just copy and paste following codes to yourdomain.com/wp-content/themes/activated-theme/fucntions.php in the most below.

How to decrease title size of WooCommerce Product

fucntions.php
Example: PHP
// Limit WooCommerce product titles​​
function astra_limit_woocommerce_product_title($title, $id = null) {
    $limit = 40; // Set the character limit you prefer
    if (strlen($title) > $limit) {
        $title = substr($title, 0, $limit) . '...';
    }
    return $title;
}
add_filter('the_title', 'astra_limit_woocommerce_product_title', 10, 2);

Output should be:

How to decrease title size of WooCommerce Product