I'm building a table with items in it. What I don't understand is the following:
When I type <td> <?php custom_get_terms('landschapspakket');?> </td>, it echoes the value of custom_get_terms('landschapspakket').
What I want to do is use some conditional logic over it to see which value it has, and then echo it. Instead it outputs it even before I type echo. Has it got something to do with the loop? How can I avoid this?
<table>
<tr>
<th>Landschapspakket</th>
<th>Be nr.</th>
<th>Gebiedscode</th>
<th>Gebruiksrecht</th>
<th>Grond</th>
<th>Aantal</th>
<th></th>
</tr>
<?php $query = new WP_Query(array('post_type' => $current_posttype, 'posts_per_page' =>'-1', 'post_status' => array('publish', 'pending', 'draft', 'private'/* , 'trash' */) ) ); ?>
<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); ?>
<tr>
<td><?php custom_get_terms('landschapspakket');?></td>
<td><?php custom_get_terms('beheerseenheidnummer');?></td>
<td><?php custom_get_terms('gebiedscode');?></td>
<td><?php custom_get_terms('gebruiksrecht');?></td>
<td><?php custom_get_terms('grond');?></td>
<td><?php custom_get_terms('stuks');?></td>
<?php $edit_post = add_query_arg('post', get_the_ID(), get_permalink(429 + $_POST['_wp_http_referer'])); ?>
<td>
<a href="<?php echo $edit_post; ?>">Bewerk</a>
<?php if( !(get_post_status() == 'trash') ) : ?>
<a onclick="return confirm('Weet je zeker dat je <?php echo get_the_title() ?> wilt verwijderen?')"href="<?php echo get_delete_post_link( get_the_ID() ); ?>">Verwijder</a>
<?php endif; ?>
</td>
</tr>
<?php endwhile; endif; ?>
</table>
If the problem is in the function custom_get_terms(), I'll include the code:
function custom_get_terms($taxonomy) {
// Get terms for post
$terms = get_the_terms( $post->ID , $taxonomy );
// Loop over each item since it's an array
if ( $terms != null ){
foreach( $terms as $term ) {
// Print the name method from $term which is an OBJECT
if ( $term->name != null ) {
print $term->name ;
// Get rid of the other data stored in the object, since it's not needed
} else {
}
unset($term);
}
}
}
