{"id":138,"date":"2015-04-23T21:57:32","date_gmt":"2015-04-24T04:57:32","guid":{"rendered":"http:\/\/lornas.wpengine.com\/?p=138"},"modified":"2015-04-23T21:57:32","modified_gmt":"2015-04-24T04:57:32","slug":"creating-a-diet-exercise-and-weight-diary-with-wordpress","status":"publish","type":"post","link":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/","title":{"rendered":"Creating a Diet, Exercise and Weight Diary with WordPress"},"content":{"rendered":"
When I started this site back up, I had a goal to daily blog so I could update my Diet, Exercise and Weight-loss journey.<\/p>\n
I almost have done daily posts (or at least semi regularly) posts. And at the end of each post I usually put my weight and or meals and exercises.<\/p>\n
I really wanted to blog just the diet stuff daily but I thought that would be too much for my subscribers and new subscribers.<\/p>\n
What I’ve done to solve this problem<\/strong><\/p>\n I’ve tried to do this all with plugins for the people who don’t want to touch code.<\/p>\n I made a custom post type with Custom Post Type UI<\/a><\/p>\n <\/p>\n I then used Advanced Custom Fields<\/a> to make 3 field groups that all are attached to the custom post type I created.<\/p>\n <\/p>\n After setting that up I needed to get the data from the custom fields into each Diet Journal post.<\/p>\n I used the example code from WPMU Dev<\/a>\u00a0and then modified to my fields.
\nHere is what I used<\/p>\n\n\n\/\/*add ACF table to Diet Journal post type entries\nadd_filter( 'the_content', 'show_diary_details' );\nfunction show_diary_details( $content ) {\n$diary = '';\nif( 'diet-journal' == get_post_type() ) {\n$diary = '<hr \/><h3>Todays Exercise<\/h3><table>\n<tr>\n<th>Activity<\/th>\n<th>Duration<\/th>\n\n<\/tr>\n<tr>\n<td>' . get_field( 'activity' ) . '<\/td>\n<td>' . get_field( 'duration' ) . ' min<\/td>\n\n<\/tr>\n<\/table>\n<h3>Weight and Measurements<\/h3>\n<table>\n<tr>\n<th>Weight<\/th>\n<th>Chest<\/th>\n<th>Waist<\/th>\n<th>Hips<\/th>\n<th>Arms<\/th>\n<th>Thighs<\/th>\n\n<\/tr>\n<tr>\n<td>' . get_field( 'weight' ) . ' lbs<\/td>\n<td>' . get_field( 'chest' ) . 'in<\/td>\n<td>' . get_field( 'waist' ) . 'in<\/td>\n<td>' . get_field( 'hips' ) . 'in<\/td>\n<td>' . get_field( 'arms' ) . 'in<\/td>\n<td>' . get_field( 'thighs' ) . 'in<\/td>\n\n<\/tr>\n<\/table>\n<h3>Todays Meals<\/h3>\n<table>\n<tr>\n<td>Breakfast<\/td>\n<td>' . get_field( 'breakfast' ) . '<\/td>\n<\/tr>\n<tr>\n<td>Lunch<\/td>\n<td>' . get_field( 'lunch' ) . '<\/td>\n<\/tr>\n<tr>\n<td>Dinner<\/td>\n<td>' . get_field( 'dinner' ) . '<\/td>\n<\/tr>\n<tr>\n<td>Snacks<\/td>\n<td>' . get_field( 'snacks' ) . '<\/td>\n<\/tr>\n<tr>\n<td>Drinks<\/td>\n<td>' . get_field( 'drinks' ) . '<\/td>\n<\/tr>\n<\/table>';\n}\nreturn $content . $diary;\n}\n\n<\/pre>\n