' . get_the_title() . '
' . spyropress_get_excerpt('by=words&length=18&link_to_post=0&ellipsis=&before_text=&after_text=') .' read more
path = dirname( __file__ ); $this->description = __( 'Display a list of recent posts.', 'spyropress' ); $this->id_base = 'srecent_posts'; $this->cssclass = 'recent-posts'; $this->name = __( 'Recent Posts', 'spyropress' ); // Fields $this->fields = array( array( 'label' => __( 'Title', 'spyropress' ), 'id' => 'title', 'type' => 'text', 'std' => $this->name ), array( 'label' => __( 'Number of items per page', 'spyropress' ), 'id' => 'limit', 'type' => 'range_slider', 'max' => 50, 'std' => 6 ), array( 'label' => __( 'Number of columns', 'spyropress' ), 'id' => 'columns', 'type' => 'range_slider', 'std' => 4, 'max' => 4 ), array( 'label' => __( 'Category', 'spyropress' ), 'id' => 'cat', 'type' => 'multi_select', 'options' => spyropress_get_taxonomies( 'category' ) ), array( 'id' => 'url_enable', 'type' => 'checkbox', 'options' => array( '1' => __( 'Show Archive Link','spyropress' ) ) ), array( 'label' => __( 'Link to Text', 'spyropress' ), 'id' => 'url_text', 'type' => 'text', 'std' => 'View All' ) ); $this->create_widget(); } function widget( $args, $instance ){ // extracting info extract( $args ); // get view to render require( $this->get_view() ); } function query( $atts, $content = null ){ $default = array( 'post_type' => 'post', 'limit' => -1, 'row_container' => 'li', 'row_class' => '', 'columns' => 2, 'pagination' => false, 'callback' => array( $this, 'generate_item' ) ); $atts = wp_parse_args( $atts, $default ); if ( !empty( $atts['cat'] ) ){ $atts['tax_query']['relation'] = 'OR'; if ( !empty( $atts['cat'] ) ){ $atts['tax_query'][] = array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => $atts['cat'], ); unset( $atts['cat'] ); } } if ( $content ) return token_repalce( $content, spyropress_query_generator( $atts ) ); return spyropress_query_generator( $atts ); } // Item HTML Generator function generate_item( $post_ID, $atts ){ // these arguments will be available from inside $content $image = array( 'post_id' => $post_ID, 'echo' => false, ); $image_tag = get_image( $image ); // item tempalte $item_tmpl = '
' . spyropress_get_excerpt('by=words&length=18&link_to_post=0&ellipsis=&before_text=&after_text=') .' read more