1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| <?php
function widget( $args, $instance ) {
extract( $args );
/* Our variables from the widget settings. */
$title = apply_filters('widget_title', $instance['title'] );
$number = $instance['number'];
$categories = $instance['categories'];
/* Before widget (defined by themes). */
echo $before_widget;
/* Display the widget title if one was input (before and after defined by themes). */
if ( $title )
echo $before_title . $title . $after_title;
?>
<ul class="middle-widget">
<?php $recent = new WP_Query(array( 'cat' => $categories, 'showposts' => $number )); $i= 0;
while($recent->have_posts()) : $recent->the_post();
$i = $i > 5 ? $i : $i++;?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" class="main-headline title_size_<?= $i?>"><?php the_title(); ?></a>
<p><?php echo excerpt(11); ?></p>
</li>
<?php endwhile; ?>
</ul>
<?php
/* After widget (defined by themes). */
echo $after_widget;
} |
Partager