WordPress query exclude post format form last posts widget

I’m currently developing a WordPress theme for a project and im looking for a way to exclude posts format from my widget and just keep the standard post format to show in the widget and i dont know where i have to put the code to exclude the post formats
and this the code of my tabs widget

<?php
add_action( 'widgets_init', 'widget_tabs_box' );
function widget_tabs_box(){
register_widget( 'widget_tabs' );
}
class widget_tabs extends WP_Widget {
function widget_tabs() {
$widget_ops = array( 'description' => 'Most Popular, Recent, Comments, Tags'  );
$this->WP_Widget( 'widget_tabs',theme_name .'- Tabbed  ', $widget_ops );
}
function widget( $args, $instance ) {
<if( empty($instance['posts_number']) || $instance['posts_number'] == ' ' || !is_numeric($instance['posts_number']))    $posts_number = 5;
    else $posts_number = $instance['posts_number'];
?>
<div class="widget" id="tabbed-widget">
    <div class="widget-container">
        <div class="widget-top">
            <ul class="tabs posts-taps">
                <li class="tabs"><a href="#tab1"><?php _e( 'Popular' , 'aya' ) ?></a></li>
                <li class="tabs"><a href="#tab2"><?php _e( 'Recent' , 'aya' ) ?></a></li>
                <li class="tabs"><a href="#tab3"><?php _e( 'Comments' , 'aya' ) ?></a></li>
                <li class="tabs" style="margin-left:0"><a href="#tab4"><?php _e( 'Tags' , 'aya' ) ?></a></li>
            </ul>
        </div>
        <div id="main-warp">
        <div id="tab1" class="tabs-wrap">
            <ul>
                             <!--latest news--> 
                <?php aya_popular_posts( $posts_number ) ?> 
            </ul>
        </div>
        <div id="tab2" class="tabs-wrap">
            <ul>
                <?php aya_last_posts( $posts_number )?> 
            </ul>
        </div>
        <div id="tab3" class="tabs-wrap">
            <ul>
                <?php  last_comments( $posts_number );?>
            </ul>
        </div>
        <div id="tab4" class="tabs-wrap tagcloud">
            <?php wp_tag_cloud( $args = array('largest' => 8,'number' => 25,'orderby'=> 'count', 'order' => 'DESC' )); ?>
        </div>
     </div> 
    </div>
</div><!-- .widget /-->
<?php
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['posts_number'] = strip_tags( $new_instance['posts_number'] );
return $instance;
}
function form( $instance ) {
$defaults = array( 'posts_number' => 5 );
$instance = wp_parse_args( (array) $instance, $defaults ); ?>
<p>
<label for="<?php echo $this->get_field_id( 'posts_number' ); ?>">Number of items to show : </label>
<input id="<?php echo $this->get_field_id( 'posts_number' ); ?>" name="<?php echo $this->get_field_name( 'posts_number' ); ?>" value="<?php echo $instance['posts_number']; ?>" size="3" type="text" />
</p>
<?php
}
}
?>

and this is the code of the last posts function

function aya_last_posts($numberOfPosts = 5 , $thumb = true){
global $post;
$orig_post = $post;
$lastPosts = get_posts('numberposts='.$numberOfPosts);
foreach($lastPosts as $post): setup_postdata($post);
?>
<?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() && $thumb ) : ?>   
   <div class="hole-post">      
    <div class="post-thumbnail">
    <a href="<?php the_permalink(); ?>" title="<?php printf( __( 'Permalink to %s', 'aya' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php aya_thumb('aya-medium'); ?><span class="overlay-icon"></span></a>
    </div><!-- post-thumbnail /-->
<?php endif; ?>
<span class="ss-view">
        <?php echo getPostViews(get_the_ID());?>
      </span>
<div class="tabtitle"><h3><a href="<?php echo get_permalink( $post->ID ) ?>" title="<?php echo the_title(); ?>"><?php echo the_title(); ?></a></h3></div>
</li></div><?php endforeach;  $post = $orig_post;  }

Related posts

Leave a Reply

1 comment

  1. If the last posts section is giving you troubles because of the image thumbnail, the fastest way would be to remove the image from the block. it seems the function accepts a second parameter so, instead of

    <?php aya_last_posts( $posts_number )?> 
    

    try with

    <?php aya_last_posts( $posts_number,false )?> 
    

    and see if it works.

    As a sidenote: I see a closing </li> element inside the function. I’m pretty sure that there was an opening tag accidentally removed.

    Edit: I saw your clarification. Look at the bennining of aya_last_posts, it says

    $lastPosts = get_posts('numberposts='.$numberOfPosts);
    

    get_posts accepts parameters such as how many posts to retrieve, and of which type.

    Just replace it with

    $lastPosts = get_posts(array('numberposts'=>$numberOfPosts,'post_type' =>'post' ));
    

    See the link to find out what else you can customize on get_posts. Perhaps you could pull only posts with a given tag or from a given category.