96 lines
3.1 KiB
PHP
96 lines
3.1 KiB
PHP
<?php
|
|
|
|
// This is supposed to prevent the symlink/absolute path issue https://github.com/elliotcondon/acf/issues/124
|
|
// see https://github.com/elliotcondon/acf/issues/124#issuecomment-118247299
|
|
add_action('init', "initHook", 0); // We use the 0 to bypass priority
|
|
function initHook() {
|
|
if(function_exists('acf')) {
|
|
acf()->settings["dir"] = WP_CONTENT_URL."/plugins/advanced-custom-fields/";
|
|
}
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'td_theme_styles' );
|
|
function td_theme_styles() {
|
|
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
|
|
wp_enqueue_script(
|
|
'google-maps',
|
|
'//maps.googleapis.com/maps/api/js?key=AIzaSyDHNT102YHu-TP50F78bPyvf5ia6K6cjU8&callback=initMap',
|
|
array(),
|
|
'1.0',
|
|
true
|
|
);
|
|
}
|
|
|
|
// 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');
|
|
|
|
// 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');
|
|
// set number of posts to 9
|
|
$query->set( 'posts_per_page', '9');
|
|
if ( !empty( $_GET['person'] ) ) {
|
|
$query->set( 'meta_query', array(
|
|
array(
|
|
'key' => 'mitreisende',
|
|
'value' => $_GET['person'],
|
|
'compare' => 'LIKE'
|
|
)
|
|
) );
|
|
}
|
|
}
|
|
}
|
|
|
|
add_action( 'pre_get_posts', 'my_home_category' );
|
|
|
|
function add_post_image_thumbs($WPQuery, $title){
|
|
if ($WPQuery->have_posts()) :
|
|
echo('<h4 style="color: white; margin-top: 20px;" class="section-inner">'.$title.'</h4>');
|
|
echo('<div class="related-posts posts section-inner">');
|
|
while ( $WPQuery->have_posts() ) : $WPQuery->the_post();
|
|
global $post;
|
|
get_template_part( 'content', get_post_format() );
|
|
endwhile;
|
|
echo('<div class="clear"></div>');
|
|
echo('</div> <!-- /related-posts -->');
|
|
endif;
|
|
}
|
|
|
|
// Related posts function
|
|
function atravelblog_related_posts() {
|
|
global $post;
|
|
$thisID = get_the_ID();
|
|
$thisUrlaubConf = array(
|
|
'posts_per_page' => -1,
|
|
'order' => 'ASC',
|
|
'meta_query' => array(
|
|
array(
|
|
'key' => 'urlaub', // name of custom field
|
|
'value' => '"'.get_the_ID().'"', // matches exaclty "123", not just 123. This prevents a match for "1234"
|
|
'compare' => 'LIKE'
|
|
)
|
|
)
|
|
);
|
|
$cat = get_the_category()[0]->name;
|
|
if ( $cat == 'Urlaub' ){
|
|
$tagebuch = new WP_Query( array_merge($thisUrlaubConf, array('category_name' => 'Tagebuch')) );
|
|
add_post_image_thumbs($tagebuch, 'Tagebuch Einträge:');
|
|
wp_reset_query();
|
|
$album = new WP_Query( array_merge($thisUrlaubConf, array('category_name' => 'Album')) );
|
|
add_post_image_thumbs($album, 'Fotoalben:');
|
|
wp_reset_query();
|
|
$tour = new WP_Query( array_merge($thisUrlaubConf, array('category_name' => 'Tour')) );
|
|
add_post_image_thumbs($tour, 'Touren:');
|
|
wp_reset_query();
|
|
} elseif($cat == 'Tour' || $cat == 'Album' || $cat == 'Tagebuch') {
|
|
$urlaub = new WP_Query(array('p' => get_field('urlaub')[0]));
|
|
add_post_image_thumbs($urlaub, 'Urlaub:');
|
|
wp_reset_query();
|
|
}
|
|
}
|