'business_x_post_list_custom_template', 'description' => esc_html__( "The most recent posts on your site", 'business-x') ); parent::__construct('categories-posts-post_template_1', esc_html__('BX : Post List View', 'business-x'), $widget_ops); $this->alt_option_name = 'widget_recent_post_post_template_1'; add_action( 'save_post', array($this, 'business_x_post_flush_widget_cache_temlate3') ); add_action( 'deleted_post', array($this, 'business_x_post_flush_widget_cache_temlate3') ); add_action( 'switch_theme', array($this, 'business_x_post_flush_widget_cache_temlate3') ); } function widget($args, $instance) { $business_x_post_cache = wp_cache_get('business_x_post_list_custom_template', 'widget'); if ( !is_array($business_x_post_cache) ) $business_x_post_cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $business_x_post_cache[ $args['widget_id'] ] ) ) { echo esc_attr($business_x_post_cache[ $args['widget_id'] ]); return; } ob_start(); extract($args); $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : esc_html__( 'Recent Posts', 'business-x' ); $post_view = ( ! empty( $instance['post-view'] ) ) ? $instance['post-view'] : 'box-view'; $number = ( ! empty( $instance['number'] ) ) ? $instance['number'] : 4; $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); ?> $number, 'post_status' => 'publish', 'ignore_sticky_posts' => true ) ) ); if ($business_x_post_r->have_posts()) : echo $args['before_widget']; if ( $title ) echo $args['before_title'] . esc_html($title) . $args['after_title']; if($post_view == 'list-view'){ ?>
    have_posts() ) : $business_x_post_r->the_post(); $post_id = get_the_ID(); $categories = get_the_category($post_id); if (has_post_thumbnail()){ $image_array = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large'); $image = $image_array[0]; }else{ $image = get_template_directory_uri() .'/assets/images/no-image.png'; } ?>
  • $cat){$class = ($key % 2 == 0)?"gaming":"business"; ?> name); ?>

have_posts()) : $business_x_post_r->the_post(); $post_id = get_the_ID(); $categories = get_the_category($post_id); if (has_post_thumbnail()) { $image_array = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'large'); $image = $image_array[0]; } else { $image = get_template_directory_uri() . '/assets/images/no-image.png'; } ?>
' ', 'prev_text' => __( '', 'business-x' ), 'next_text' => __( '', 'business-x' ))); wp_reset_postdata(); ?> business_x_post_flush_widget_cache_temlate3(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset($alloptions['business_x_post_list_custom_template']) ) delete_option('business_x_post_list_custom_template'); return $instance; } function business_x_post_flush_widget_cache_temlate3() { wp_cache_delete('business_x_post_list_custom_template', 'widget'); } function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 3; $post_view = isset( $instance['post-view'] ) ? esc_attr( $instance['post-view'] ) : ''; ?>