aşağıdaki kod wordpress eklentisinde 27 IDli kategorideki son postlarından 1 er tane çekiyor. okey buraya kadar herşey normal ama sitede 7 userin 27 idsine sahip kategoride yazısı var ve dolayısıyla 7sinide gösteriyor. en son 4 ünü göstersin şeklinde bidüzenleyemedim amatörüm yardımcı olabilecek varmı
<?php
/**
* Plugin Name: KÖŞE YAZARLARI
*/
add_action( 'widgets_init', 'xturk_yazarlar_load_widgets' );
function xturk_yazarlar_load_widgets() {
register_widget( 'xturk_yazarlar_widget' );
}
class xturk_yazarlar_widget extends WP_Widget {
function xturk_yazarlar_widget() {
$widget_ops = array( 'classname' => 'xturk_yazarlar_widget', 'description' => __('Sidebar\'da Yazarları gösterir.', 'xturk_yazarlar_widget') );
$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'xturk_yazarlar_widget' );
$this->WP_Widget( 'xturk_yazarlar_widget', __('(X) Sidebar: Yazarlar', 'xturk_yazarlar_widget'), $widget_ops, $control_ops );
}
function widget( $args, $instance ) {extract( $args );
$title = apply_filters('widget_title', $instance['title'] );
$number = $instance['number'];
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
?>
<div class="babil-sidebar-yazarlar">
<ul>
<?php global $wpdb; $authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE ID NOT IN(1) ORDER BY (SELECT post_date FROM $wpdb->posts WHERE post_author=$wpdb->users.ID ORDER BY post_date DESC LIMIT 1) DESC");
$args = array(
'posts_per_page' => 1,
'author' => $author->ID
);
$posts = new WP_Query( $args );
$count = count( $posts );
foreach($authors as $author) { ?>
<?php query_posts(array('cat' => '27', 'showposts' => 1, 'author' => $author->ID )); if(have_posts()) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" target="_blank">
<li>
<div class="babil-sidebar-yazarlar-gorsel"><?php userphoto_the_author_photo(
'',
'',
array('width' => '110','height' => '110'),
get_bloginfo('template_url').'/images/avatar.png'
) ?></div>
<div class="babil-sidebar-yazarlar-isim"><h4><?php echo get_the_author_meta('display_name', $author->ID); ?></h4></div>
<div class="babil-sidebar-yazarlar-spot"><p><?php the_title(); ?></p></div>
</li>
</a>
<?php endwhile; ?>
<?php endif; ?>
<?php } ?>
</ul>
</div>
<?php echo $after_widget; }
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['number'] = strip_tags( $new_instance['number'] );
return $instance;
}
function form( $instance ) {
$defaults = array( 'number' => 3);
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Başlık:</label>
<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:90%;" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'number' ); ?>">Kaç haber gösterilsin:</label>
<input id="<?php echo $this->get_field_id( 'number' ); ?>" name="<?php echo $this->get_field_name( 'number' ); ?>" value="<?php echo $instance['number']; ?>" style="width:90%;"/>
</p>
<?php
}
}
?>