atravelblog/functions.php

53 lines
1.6 KiB
PHP
Raw Normal View History

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-11 16:59:35 +02:00
2016-09-11 16:28:51 +02:00
// Related posts function
function atravelblog_related_posts() {
echo('<div class="related-posts posts section-inner">');
global $post;
$thisID = get_the_ID();
$cat = get_the_category()[0]->name;
if ( $cat == 'Urlaub' ){
$tagebuch = new WP_Query( array( 'category_name' => 'Tagebuch' ) );
if ($tagebuch->have_posts()) :
2016-09-12 12:52:08 +02:00
echo('<h4>Tagebuch Einträge:</h4>');
while ( $tagebuch->have_posts() ) : $tagebuch->the_post();
global $post;
if($thisID == get_field('urlaub')->ID){
get_template_part( 'content', get_post_format() );
}
endwhile;
endif;
} elseif($cat == 'Tour') {
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()) :
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;
endif;
}
2016-09-12 12:35:03 +02:00
echo('<div class="clear"></div>');
echo('</div> <!-- /related-posts -->');
wp_reset_query();
2016-09-11 16:59:35 +02:00
}