wir
9/17/2015 - 4:20 PM

Travel Diary

Travel Diary

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;
}
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;
}
<?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>
wp_enqueue_script(
  'google-maps',
  '//maps.googleapis.com/maps/api/js?key=your_api_key&callback=initMap',
  array(),
  '1.0',
  true
);
	<th><a href='<?php echo site_url( '?meta_key=difficulty&meta_value=' . get_field('difficulty') ) ?>'><?php the_field( 'difficulty' ) ?></a></th>
<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>
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' );
add_action( 'wp_enqueue_scripts', 'td_theme_styles' );
function td_theme_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
/*
 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
*/
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' );