Last active
September 22, 2015 03:24
-
-
Save danielpataki/7d9788a0eca709ecee9a to your computer and use it in GitHub Desktop.
Travel 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
function td_admin_assets() { | |
wp_enqueue_style( 'td-admin-post-list', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.0.0' ); | |
} | |
add_action( 'admin_enqueue_scripts', 'td_admin_assets' ); |
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: Travel Diary | |
Theme URI: http://danielpataki.com | |
Description: My travel diary theme, a child of Yuuta | |
Author: Daniel Pataki | |
Author URI: http://danielpataki.com | |
Template: yuuta | |
Version: 1.0.0 | |
License: GNU General Public License v2 or later | |
License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
Text Domain: traveldiary | |
*/ |
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_action( 'wp_enqueue_scripts', 'td_theme_styles' ); | |
function td_theme_styles() { | |
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); | |
} |
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
function td_custom_filtering( $query ) { | |
if ( $query->is_home() && $query->is_main_query() && !empty( $_GET['meta_key'] ) && !empty( $_GET['meta_value'] ) ) { | |
$query->set( 'meta_key', $_GET['meta_key'] ); | |
$query->set( 'meta_value', $_GET['meta_value'] ); | |
} | |
} | |
add_action( 'pre_get_posts', 'td_custom_filtering' ); |
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
<table> | |
<tr> | |
<th>Length</th> | |
<th>Duration</th> | |
<th>Difficulty</th> | |
<th>Trail Map</th> | |
</tr> | |
<tr> | |
<th><?php the_field( 'length' ) ?></th> | |
<th><?php the_field( 'duration' ) ?></th> | |
<th><?php the_field( 'difficulty' ) ?></th> | |
<th><a href='<?php the_field( 'trail_map' ) ?>'>View Map</a></th> | |
</tr> | |
</table> |
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
<th><a href='<?php echo site_url( '?meta_key=difficulty&meta_value=' . get_field('difficulty') ) ?>'><?php the_field( 'difficulty' ) ?></a></th> |
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
wp_enqueue_script( | |
'google-maps', | |
'//maps.googleapis.com/maps/api/js?key=your_api_key&callback=initMap', | |
array(), | |
'1.0', | |
true | |
); |
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 $location = get_field( 'location' ); ?> | |
<h6>Location: <small><?php echo round( $location['lat'], 4 ) ?>, <?php echo round( $location['lng'], 4 ) ?></small></h6> | |
<div class='map' style='height:300px; margin-bottom: 1.6842em' id='map-<?php echo $id ?>'></div> | |
<script type='text/javascript'> | |
var map; | |
var map_center = {lat: <?php echo $location['lat'] ?>, lng: <?php echo $location['lng'] ?> }; | |
function initMap() { | |
map = new google.maps.Map(document.getElementById('map-<?php echo $id ?>'), { | |
center: map_center, | |
zoom: 15 | |
}); | |
var marker = new google.maps.Marker({ | |
position: map_center, | |
map: map | |
}); | |
} | |
</script> |
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('manage_post_posts_columns', 'td_post_columns'); | |
function td_post_columns( $defaults ) { | |
$columns = array(); | |
$columns['cb'] = $defaults['cb']; | |
unset( $defaults['tags'], $defaults['author'], $defaults['cb'] ); | |
$columns['days'] = "Days"; | |
$columns = array_merge( $columns, $defaults ); | |
return $columns; | |
} |
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( 'manage_edit-post_sortable_columns', 'td_post_column_ordering' ); | |
function td_post_column_ordering( $columns ) { | |
$columns['days'] = 'days'; | |
return $columns; | |
} | |
add_filter( 'request', 'td_post_column_ordering_request' ); | |
function td_post_column_ordering_request( $vars ) { | |
if ( isset( $vars['orderby'] ) && 'days' == $vars['orderby'] ) { | |
$vars = array_merge( $vars, array( | |
'meta_key' => 'days', | |
'orderby' => 'meta_value_num', | |
) ); | |
} | |
return $vars; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment