I am working on a foreach loop in WordPress and want to add ‘post_class()’ to a div within it. Currently the code looks like this:
if ( is_array( $posts ) && !empty( $posts ) ) {
echo '<ul class="tribe-related-events tribe-clearfix hfeed vcalendar">';
foreach ( $posts as $post ) {
echo '<li>';
echo '<div class="overlay">';
echo '<div '. post_class() .'>';
echo '<h3>'. tribe_get_event_taxonomy() .'</h3>';
echo '</div>';
echo '</div>';
echo '</li>';
}
echo '</ul>';
}
The ‘post_class()’ function is breaking the div it is in and calling the classes as if they were content in the page.
Any ideas?