Fix related posts function

This commit is contained in:
Markus Ankenbrand 2016-09-11 16:59:35 +02:00
parent 93a959e8dd
commit e747b84332
2 changed files with 48 additions and 53 deletions

View file

@ -20,32 +20,28 @@ function my_acf_google_map_api( $api ){
add_filter('acf/fields/google_map/api', 'my_acf_google_map_api');
// Related posts function
function atravelblog_related_posts() {
echo('<div class="related-posts posts section-inner">');
global $post;
if ( get_the_category()[0]->name == 'Urlaub' ){
$tagebuch = get_posts(array(
'category_name' => 'Tagebuch'
));
echo('<div class="related-posts posts section-inner">');
global $post;
$thisID = get_the_ID();
if ( get_the_category()[0]->name == 'Urlaub' ){
$tagebuch = new WP_Query( array( 'category_name' => 'Tagebuch' ) );
if ($tagebuch->have_posts()) :
while ( $tagebuch->have_posts() ) : $tagebuch->the_post(); ?>
if ($tagebuch->have_posts()) :
while ( $tagebuch->have_posts() ) : $tagebuch->the_post();
global $post;
if($thisID == get_field('urlaub')->ID){
get_template_part( 'content', get_post_format() );
}
endwhile;
endif;
echo('<div class="clear"></div>');
echo('</div> <!-- /related-posts -->');
wp_reset_query();
<?php global $post; ?>
}
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php endif; ?>
<div class="clear"></div>
<?php wp_reset_query(); ?>
</div> <!-- /related-posts --> <?php
}
}
}