2016-09-07 20:11:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
add_action( 'wp_enqueue_scripts', 'td_theme_styles' );
|
|
|
|
|
function td_theme_styles() {
|
|
|
|
|
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
|
2016-09-07 21:09:58 +02:00
|
|
|
wp_enqueue_script(
|
|
|
|
|
'google-maps',
|
|
|
|
|
'//maps.googleapis.com/maps/api/js?key=AIzaSyDHNT102YHu-TP50F78bPyvf5ia6K6cjU8&callback=initMap',
|
|
|
|
|
array(),
|
|
|
|
|
'1.0',
|
|
|
|
|
true
|
|
|
|
|
);
|
2016-09-07 20:11:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add google API key
|
|
|
|
|
function my_acf_google_map_api( $api ){
|
|
|
|
|
$api['key'] = 'AIzaSyDHNT102YHu-TP50F78bPyvf5ia6K6cjU8';
|
|
|
|
|
return $api;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
|
2016-09-11 16:28:51 +02:00
|
|
|
|
2016-09-12 19:37:08 +02:00
|
|
|
// Only show posts of category Urlaub (id=2)
|
|
|
|
|
function my_home_category( $query ) {
|
|
|
|
|
if ( $query->is_home() && $query->is_main_query() ) {
|
|
|
|
|
$query->set( 'cat', '2');
|
2016-09-12 20:01:49 +02:00
|
|
|
if ( !empty( $_GET['person'] ) ) {
|
|
|
|
|
$query->set( 'meta_query', array(
|
2016-09-12 21:28:43 +02:00
|
|
|
array(
|
|
|
|
|
'key' => 'mitreisende',
|
|
|
|
|
'value' => $_GET['person'],
|
|
|
|
|
'compare' => 'LIKE'
|
|
|
|
|
)
|
2016-09-12 20:01:49 +02:00
|
|
|
) );
|
|
|
|
|
}
|
2016-09-12 19:37:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add_action( 'pre_get_posts', 'my_home_category' );
|
2016-09-11 16:59:35 +02:00
|
|
|
|
2016-09-11 16:28:51 +02:00
|
|
|
// Related posts function
|
|
|
|
|
function atravelblog_related_posts() {
|
2016-09-12 12:29:05 +02:00
|
|
|
global $post;
|
|
|
|
|
$thisID = get_the_ID();
|
|
|
|
|
$cat = get_the_category()[0]->name;
|
|
|
|
|
if ( $cat == 'Urlaub' ){
|
2016-09-12 12:59:53 +02:00
|
|
|
$tagebuch = new WP_Query( array(
|
|
|
|
|
'category_name' => 'Tagebuch',
|
2016-09-12 13:12:20 +02:00
|
|
|
'posts_per_page' => -1,
|
2016-09-12 21:16:11 +02:00
|
|
|
'order' => 'ASC',
|
2016-09-12 13:12:20 +02:00
|
|
|
'meta_query' => array(
|
|
|
|
|
array(
|
|
|
|
|
'key' => 'urlaub', // name of custom field
|
2016-09-12 21:05:04 +02:00
|
|
|
'value' => '"'.get_the_ID().'"', // matches exaclty "123", not just 123. This prevents a match for "1234"
|
|
|
|
|
'compare' => 'LIKE'
|
2016-09-12 13:12:20 +02:00
|
|
|
)
|
|
|
|
|
)
|
2016-09-12 12:59:53 +02:00
|
|
|
) );
|
2016-09-12 12:29:05 +02:00
|
|
|
if ($tagebuch->have_posts()) :
|
2016-09-12 13:30:01 +02:00
|
|
|
echo('<h4 style="color: white; margin-top: 20px;" class="section-inner">Tagebuch Einträge:</h4>');
|
2016-09-12 12:55:49 +02:00
|
|
|
echo('<div class="related-posts posts section-inner">');
|
2016-09-12 12:29:05 +02:00
|
|
|
while ( $tagebuch->have_posts() ) : $tagebuch->the_post();
|
|
|
|
|
global $post;
|
2016-09-12 13:12:20 +02:00
|
|
|
get_template_part( 'content', get_post_format() );
|
2016-09-12 12:29:05 +02:00
|
|
|
endwhile;
|
2016-09-12 12:55:49 +02:00
|
|
|
echo('<div class="clear"></div>');
|
|
|
|
|
echo('</div> <!-- /related-posts -->');
|
2016-09-12 12:29:05 +02:00
|
|
|
endif;
|
2016-09-12 12:55:49 +02:00
|
|
|
wp_reset_query();
|
2016-09-12 13:36:50 +02:00
|
|
|
$album = new WP_Query( array(
|
|
|
|
|
'category_name' => 'Album',
|
|
|
|
|
'posts_per_page' => -1,
|
2016-09-12 21:16:11 +02:00
|
|
|
'order' => 'ASC',
|
2016-09-12 13:36:50 +02:00
|
|
|
'meta_query' => array(
|
|
|
|
|
array(
|
|
|
|
|
'key' => 'urlaub', // name of custom field
|
2016-09-12 21:05:04 +02:00
|
|
|
'value' => '"'.get_the_ID().'"', // matches exaclty "123", not just 123. This prevents a match for "1234"
|
|
|
|
|
'compare' => 'LIKE'
|
2016-09-12 13:36:50 +02:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
) );
|
|
|
|
|
if ($album->have_posts()) :
|
|
|
|
|
echo('<h4 style="color: white; margin-top: 20px;" class="section-inner">Fotoalben:</h4>');
|
|
|
|
|
echo('<div class="related-posts posts section-inner">');
|
|
|
|
|
while ( $album->have_posts() ) : $album->the_post();
|
|
|
|
|
global $post;
|
|
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
|
endwhile;
|
|
|
|
|
echo('<div class="clear"></div>');
|
|
|
|
|
echo('</div> <!-- /related-posts -->');
|
|
|
|
|
endif;
|
|
|
|
|
wp_reset_query();
|
2016-09-12 13:38:27 +02:00
|
|
|
$touren = new WP_Query( array(
|
|
|
|
|
'category_name' => 'Tour',
|
|
|
|
|
'posts_per_page' => -1,
|
2016-09-12 21:16:11 +02:00
|
|
|
'order' => 'ASC',
|
2016-09-12 13:38:27 +02:00
|
|
|
'meta_query' => array(
|
|
|
|
|
array(
|
|
|
|
|
'key' => 'urlaub', // name of custom field
|
2016-09-12 21:05:04 +02:00
|
|
|
'value' => '"'.get_the_ID().'"', // matches exaclty "123", not just 123. This prevents a match for "1234"
|
|
|
|
|
'compare' => 'LIKE'
|
2016-09-12 13:38:27 +02:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
) );
|
|
|
|
|
if ($touren->have_posts()) :
|
|
|
|
|
echo('<h4 style="color: white; margin-top: 20px;" class="section-inner">Touren:</h4>');
|
|
|
|
|
echo('<div class="related-posts posts section-inner">');
|
|
|
|
|
while ( $touren->have_posts() ) : $touren->the_post();
|
|
|
|
|
global $post;
|
|
|
|
|
get_template_part( 'content', get_post_format() );
|
|
|
|
|
endwhile;
|
|
|
|
|
echo('<div class="clear"></div>');
|
|
|
|
|
echo('</div> <!-- /related-posts -->');
|
|
|
|
|
endif;
|
|
|
|
|
wp_reset_query();
|
2016-09-12 13:39:32 +02:00
|
|
|
} elseif($cat == 'Tour' || $cat == 'Album' || $cat == 'Tagebuch') {
|
2016-09-12 12:51:51 +02:00
|
|
|
$urlaub = new WP_Query(array('p' => get_field('urlaub')[0]));
|
2016-09-12 12:35:03 +02:00
|
|
|
if ($urlaub->have_posts()) :
|
2016-09-12 13:30:01 +02:00
|
|
|
echo('<h4 style="color: white; margin-top: 20px;" class="section-inner">Urlaub:</h4>');
|
2016-09-12 12:55:49 +02:00
|
|
|
echo('<div class="related-posts posts section-inner">');
|
2016-09-12 12:35:03 +02:00
|
|
|
while ( $urlaub->have_posts() ) : $urlaub->the_post();
|
|
|
|
|
global $post;
|
2016-09-12 12:52:08 +02:00
|
|
|
get_template_part( 'content', get_post_format() );
|
2016-09-12 12:35:03 +02:00
|
|
|
endwhile;
|
2016-09-12 12:55:49 +02:00
|
|
|
echo('<div class="clear"></div>');
|
|
|
|
|
echo('</div> <!-- /related-posts -->');
|
2016-09-12 12:35:03 +02:00
|
|
|
endif;
|
2016-09-12 12:55:49 +02:00
|
|
|
wp_reset_query();
|
2016-09-12 12:29:05 +02:00
|
|
|
}
|
2016-09-11 16:59:35 +02:00
|
|
|
}
|