esc_html__( 'Displays your latest listings. Outputs the post thumbnail, title and date per listing','breeze'))
);
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['numberOfListings'] = strip_tags($new_instance['numberOfListings']);
$instance['cat'] = strip_tags($new_instance['cat']);
return $instance;
}
function form($instance) {
$instance = wp_parse_args( ( array ) $instance, array(
'title' => '',
'cat' => 0,
'numberOfListings' => get_option('posts_per_page'),
));
$title = esc_attr($instance['title']);
$numberOfListings = esc_attr($instance['numberOfListings']);
$cat = $instance['cat'];
?>
term_id;
// Get the URL of this category
$category_link = get_category_link( $category_id );
echo $before_widget;
if ( $title ) {
echo ''.$before_title . $title . $after_title.'
';
}
$posts_args = array(
'post_type' => 'post',
'category_name' => $cat,
'posts_per_page' => $numberOfListings,
'order' => 'DESC'
);
global $post;
//add_image_size( 'realty_widget_size', 85, 45, false );
$listings = new WP_Query($posts_args);
$author_details = '';
$user_content = '';
// Get author's display name
$display_name = get_the_author_meta( 'display_name', $post->post_author );
// If display name is not available then use nickname as display name
if ( empty( $display_name ) )
$display_name = get_the_author_meta( 'nickname', $post->post_author );
// Get author's biographical information or description
$user_description = get_the_author_meta( 'user_description', $post->post_author );
// Get author's website URL
$user_website = get_the_author_meta('url', $post->post_author);
$user_image = get_avatar( get_the_author_meta('user_email') , 40 );
// Get link to the author archive page
$user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
if($listings->found_posts > 0) {
echo '';
wp_reset_postdata();
}else{
echo 'No listing found
';
}
echo $after_widget;
}
} //end class Realty_Widget
function breeze_register_posts_display_widget_init() {
register_widget( 'Breeze_Posts_Display_Widget' );
}
add_action( 'widgets_init', 'breeze_register_posts_display_widget_init');