in a custom plugin I have a WPQuery, which looks like the following:
$sticky = get_option( 'sticky_posts' );
$args = array(
'post_type' => 'mission',
'ignore_sticky_posts' => 1,
'orderby' => 'date',
'post__not_in' => $sticky,
'posts_per_page' => $count
);
$latest_missions = new WP_Query( $args );
if ( $latest_missions->have_posts() ) {
while ( $latest_missions->have_posts() ) {
$latest_missions->the_post();
get_template_part( 'content-list', get_post_format() );
}
wp_reset_postdata();
}
and the corresponding template part:
<li id="post-<?php the_ID(); ?> " class="future-event"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></li>
The only problem I have is, that this will no produce semantic correct HTML, because the list is not sematically correct.
Is there a way, how I can create an <ul></ul>
which is wrapped around the list, when my loop is finished?
BR,
mybecks
Of course there is. Just do it like this: