Last active
August 29, 2015 14:12
-
-
Save danielpataki/df3c87c0529b2cf26c23 to your computer and use it in GitHub Desktop.
Workout Diary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'the_content', 'show_diary_details' ); | |
function show_diary_details( $content ) { | |
$diary = ''; | |
if( has_category( 'workout' ) ) { | |
$diary = '<table> | |
<tr> | |
<th>Activity</th> | |
<th>Duration</th> | |
<th>Distance</th> | |
<th>Calories</th> | |
<th>Link</th> | |
</tr> | |
<tr> | |
<td>' . get_field( 'type' ) . '</td> | |
<td>' . get_field( 'duration' ) . ' min</td> | |
<td>' . get_field( 'distance' ) . ' km</td> | |
<td>' . get_field( 'calories' ) . ' kcal</td> | |
<td><a href="' . get_field( 'link' ) . '">link</a></td> | |
</tr> | |
</table>'; | |
} | |
if( has_category( 'meal' ) ) { | |
$diary = '<table> | |
<tr> | |
<th>Calories</th> | |
<th>Fat</th> | |
<th>Protein</th> | |
<th>Carbohydrates</th> | |
<th>Cholesterol</th> | |
</tr> | |
<tr> | |
<td>' . get_field( 'calories' ) . ' kcal</td> | |
<td>' . get_field( 'fat' ) . ' g</td> | |
<td>' . get_field( 'protein' ) . ' g</td> | |
<td>' . get_field( 'carbohydrates' ) . ' g</td> | |
<td>' . get_field( 'cholesterol' ) . ' mg</td> | |
</tr> | |
</table>'; | |
} | |
if( has_category( 'sleep' ) ) { | |
$diary = '<table> | |
<tr> | |
<th>Calories</th> | |
<th>Fat</th> | |
<th>Protein</th> | |
<th>Carbohydrates</th> | |
<th>Cholesterol</th> | |
</tr> | |
<tr> | |
<td>' . get_field( 'start' ) . '</td> | |
<td>' . get_field( 'end' ) . '</td> | |
</tr> | |
</table>'; | |
} | |
return $content . $diary; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); | |
function theme_enqueue_styles() { | |
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ) ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: Workout Diary | |
Theme URI: http://yourwebsite.com/ | |
Description: My personal workout diary | |
Author: Daniel Pataki | |
Author URI: http://danielpataki.com | |
Template: twentyfifteen | |
Version: 1.0.0 | |
License: GNU General Public License v2 or later | |
License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'the_content', 'show_diary_details' ); | |
function show_diary_details( $content ) { | |
$diary = ''; | |
if( has_category( 'workout' ) ) { | |
$diary = '<table> | |
<tr> | |
<th>Activity</th> | |
<th>Duration</th> | |
<th>Distance</th> | |
<th>Calories</th> | |
<th>Link</th> | |
</tr> | |
<tr> | |
<td>' . get_field( 'type' ) . '</td> | |
<td>' . get_field( 'duration' ) . ' min</td> | |
<td>' . get_field( 'distance' ) . ' km</td> | |
<td>' . get_field( 'calories' ) . ' kcal</td> | |
<td><a href="' . get_field( 'link' ) . '">link</a></td> | |
</tr> | |
</table>'; | |
} | |
return $content . $diary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment