Types is a WordPress plugin that lets you easily create custom post types and add your own types of data to your website through the WordPress admin screen. You can also associate the content types with taxonomies and fields.
When you ask for help or report issues, make sure to tell us what you have created so far and what you want to achieve.
Viewing 15 topics - 1,321 through 1,335 (of 1,516 total)
Problem:
How to calculate current age using birthdate custom field.
Solution:
To calculate the age using custom field you need to write custom shortcode:
Add following code to your current theme's functions.php file:
add_shortcode( 'time_ago', 'time_ago_func');
function time_ago_func($atts){
global $wpdb;
extract( shortcode_atts( array(
'birthdate' => '',
), $atts ) );
//explode the date to get month, day and year
//$birthDate = explode("-", $birthDate);
//get age from date or birthdate
//$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));
$age = floor((time() - $birthdate)/(365*24*60*60));
return $age;
}