Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: widget_posts_args

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
556           }
557
558           ob_start();
559           extract($args);
560
561           $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts') : $instance['title'], $instance, $this->id_base);
562           if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) )
563                 $number = 10;
564
565           $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) );
566           if ($r->have_posts()) :
567 ?>
568           <?php echo $before_widget; ?>
569           <?php if ( $title ) echo $before_title . $title . $after_title; ?>
570           <ul>
571           <?php  while ($r->have_posts()) : $r->the_post(); ?>
572           <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li>
573           <?php endwhile; ?>
574           </ul>