add_filter('the_content','my_function');
function my_function($content){
the_post_thumbnail('thumbnail', array('class' => 'top-post-img' ));
if (is_single() && in_category('5')){
global $post;
$term_list = wp_get_post_terms ($post->ID,'school',array('fields'=>'names'));
?>
<div id="some_class">
<span>School:<strong><?php print_r($term_list[0]); ?></strong></span>
<?php
if (is_single() && in_category('5')){
$term_list = wp_get_post_terms ($post->ID,'article',array('fields' =>'names'));
?>
<span>Article:<strong><?php print_r($term_list[0]); ?></strong></span>
<?php
if (is_single() && in_category('5')){
$term_list = wp_get_post_terms ($post->ID,'teacher',array('fields'=>'names'));
?>
<span>Teacher:<strong><?php print_r($term_list[0]); ?></strong></span>
</div>
<?php
return $content;
}
}
} else {
return $content;
}
}
Thanks to suggestions made by Rarst, this code works like a charm.
As you can see, it does show the Featured Image
which belongs to that post,
and the output is returned in exact order as wished in the code.
It also uses some CSS to style (in the style.css) so it shows nice below
the title and above the content.
Update
Getting Notice: Undefined offset: 0
Anyone around to help me out?