{"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

\"diet-journal-cpt\"<\/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

\"field-groups\"<\/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

I probably could have used ACF Short Codes<\/a>. But the above code added to function.php makes this automatic for now.<\/p>\n

The next goal is to integrate Google Charts to pull data from the custom fields and make a fancy chart.
\nI then used a Recent Posts widget on the sidebar to list the latest Diet Journal post.<\/p>\n

You can also see my latest here -> Day 4<\/a><\/p>\n","protected":false},"excerpt":{"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. 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. I really…<\/p>\n","protected":false},"author":1,"featured_media":141,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11],"tags":[],"yoast_head":"\nCreating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com\" \/>\n<meta property=\"og:description\" content=\"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. 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. I really…\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Loren Nason dot com\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-24T04:57:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/lorennason.com\/wp-content\/uploads\/2015\/04\/journal.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"260\" \/>\n\t<meta property=\"og:image:height\" content=\"395\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Loren Nason\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Loren Nason\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/\",\"url\":\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/\",\"name\":\"Creating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com\",\"isPartOf\":{\"@id\":\"https:\/\/lorennason.com\/#website\"},\"datePublished\":\"2015-04-24T04:57:32+00:00\",\"dateModified\":\"2015-04-24T04:57:32+00:00\",\"author\":{\"@id\":\"https:\/\/lorennason.com\/#\/schema\/person\/7221f486a08714e11e69191b07090f86\"},\"breadcrumb\":{\"@id\":\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lorennason.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating a Diet, Exercise and Weight Diary with WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lorennason.com\/#website\",\"url\":\"https:\/\/lorennason.com\/\",\"name\":\"Loren Nason dot com\",\"description\":\"My thoughts on Life, Tech, WordPress, and other stuff I do\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lorennason.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/lorennason.com\/#\/schema\/person\/7221f486a08714e11e69191b07090f86\",\"name\":\"Loren Nason\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lorennason.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ba0a29282967c8d869a53e8c6fd42471?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ba0a29282967c8d869a53e8c6fd42471?s=96&d=mm&r=g\",\"caption\":\"Loren Nason\"},\"url\":\"https:\/\/lorennason.com\/author\/lorennason\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"Creating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com","og_description":"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. 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. I really…","og_url":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/","og_site_name":"Loren Nason dot com","article_published_time":"2015-04-24T04:57:32+00:00","og_image":[{"width":260,"height":395,"url":"https:\/\/lorennason.com\/wp-content\/uploads\/2015\/04\/journal.jpg","type":"image\/jpeg"}],"author":"Loren Nason","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Loren Nason","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/","url":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/","name":"Creating a Diet, Exercise and Weight Diary with WordPress - Loren Nason dot com","isPartOf":{"@id":"https:\/\/lorennason.com\/#website"},"datePublished":"2015-04-24T04:57:32+00:00","dateModified":"2015-04-24T04:57:32+00:00","author":{"@id":"https:\/\/lorennason.com\/#\/schema\/person\/7221f486a08714e11e69191b07090f86"},"breadcrumb":{"@id":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/lorennason.com\/2015\/04\/creating-a-diet-exercise-and-weight-diary-with-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lorennason.com\/"},{"@type":"ListItem","position":2,"name":"Creating a Diet, Exercise and Weight Diary with WordPress"}]},{"@type":"WebSite","@id":"https:\/\/lorennason.com\/#website","url":"https:\/\/lorennason.com\/","name":"Loren Nason dot com","description":"My thoughts on Life, Tech, WordPress, and other stuff I do","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lorennason.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/lorennason.com\/#\/schema\/person\/7221f486a08714e11e69191b07090f86","name":"Loren Nason","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lorennason.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ba0a29282967c8d869a53e8c6fd42471?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ba0a29282967c8d869a53e8c6fd42471?s=96&d=mm&r=g","caption":"Loren Nason"},"url":"https:\/\/lorennason.com\/author\/lorennason\/"}]}},"_links":{"self":[{"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/posts\/138"}],"collection":[{"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":0,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/media\/141"}],"wp:attachment":[{"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lorennason.com\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}