Creating a Diet, Exercise and Weight Diary with WordPress

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 wanted to blog just the diet stuff daily but I thought that would be too much for my subscribers and new subscribers.

What I’ve done to solve this problem

I’ve tried to do this all with plugins for the people who don’t want to touch code.

I made a custom post type with Custom Post Type UI


I then used Advanced Custom Fields to make 3 field groups that all are attached to the custom post type I created.


After setting that up I needed to get the data from the custom fields into each Diet Journal post.

I used the example code from WPMU Dev and then modified to my fields.
Here is what I used

//*add ACF table to Diet Journal post type entries
add_filter( 'the_content', 'show_diary_details' );
function show_diary_details( $content ) {
$diary = '';
if( 'diet-journal' == get_post_type() ) {
$diary = '<hr /><h3>Todays Exercise</h3><table>

<td>' . get_field( 'activity' ) . '</td>
<td>' . get_field( 'duration' ) . ' min</td>

<h3>Weight and Measurements</h3>

<td>' . get_field( 'weight' ) . ' lbs</td>
<td>' . get_field( 'chest' ) . 'in</td>
<td>' . get_field( 'waist' ) . 'in</td>
<td>' . get_field( 'hips' ) . 'in</td>
<td>' . get_field( 'arms' ) . 'in</td>
<td>' . get_field( 'thighs' ) . 'in</td>

<h3>Todays Meals</h3>
<td>' . get_field( 'breakfast' ) . '</td>
<td>' . get_field( 'lunch' ) . '</td>
<td>' . get_field( 'dinner' ) . '</td>
<td>' . get_field( 'snacks' ) . '</td>
<td>' . get_field( 'drinks' ) . '</td>
return $content . $diary;

I probably could have used ACF Short Codes. But the above code added to function.php makes this automatic for now.

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

You can also see my latest here -> Day 4

Some of the links in all posts may be affiliate links, which means I may get a commission if you end up purchasing their product or service. You will never pay more by using my link compared to what you would pay if you went directly to their website; in fact you may receive an exclusive discount. And it helps me keep the site running!

Posted in ,

Loren Nason

Leave a Comment