'', 'show' => 6, 'desc' => true, 'autoslide' => 0, 'cats' => null ); /* Widget setup */ function __construct() { /* Widget settings. */ $widget_ops = array( 'description' => __('A widget with slider', LANGUAGE_ZONE) ); /* Create the widget. */ parent::__construct( 'dt-slider-widget', DT_WIDGET_PREFIX . __('Slider', LANGUAGE_ZONE), $widget_ops ); } /* Display the widget */ function widget( $args, $instance ) { extract( $args ); $instance = wp_parse_args( (array) $instance, $this->dt_defaults ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); $autoslide = $instance['autoslide']; $autoslide_on = $autoslide ? 1 : 0; global $wpdb, $post; $args = array( 'no_found_rows' => 1, 'posts_per_page' => 1 , 'post_type' => 'dt_slider', 'post_status' => 'publish', 'post__in' => array($instance['cats']) ); $p_query = new WP_Query( $args ); echo $before_widget ; // start echo $before_title . $title . $after_title; ?>
have_posts() ) { $slides_arr = array(); foreach( $p_query->posts as $album ) { $args = array( 'no_found_rows' => 1, 'posts_per_page' => $instance['show'], 'post_type' => 'attachment', 'post_mime_type' => 'image', 'post_parent' => $album->ID, 'post_status' => 'inherit', 'orderby' => 'menu_order', 'order' => 'ASC' ); $images = new WP_Query( $args ); if( $images->have_posts() ) { while( $images->have_posts() ) { $images->the_post(); $link = get_post_meta( $post->ID, '_dt_slider_link', true ); $hide_desc = ! ! get_post_meta( $post->ID, '_dt_slider_hdesc', true ); $link_neww = get_post_meta( $post->ID, '_dt_slider_newwin', true ); $tmp_arr = array(); if ( ! empty( $post->post_excerpt ) && ! $hide_desc ) { $tmp_arr['caption'] = wp_trim_words( get_the_excerpt(), 15, '' ); } if ( ! empty( $link ) ) { $tmp_arr['link'] = $link; } if ( ! empty( $link_neww ) ) { $tmp_arr['link_neww'] = true; } if ( ! empty( $post->post_title ) && ! $hide_desc ) $tmp_arr['title'] = $post->post_title; $img = wp_get_attachment_image_src( $post->ID, 'full' ); if( $img ) { $tmp_arr['src'] = str_replace( array('src="', '"'), '', dt_get_thumb_img( array( 'img_meta' => $img, 'thumb_opts' => array( 'w' => 210, 'h' => 210 ) ), '%SRC%', false ) ); $tmp_arr['size_str'] = image_hwstring( 210, 210 ); $tmp_arr['alt'] = esc_attr( get_post_meta( $post->ID, '_wp_attachment_image_alt', true ) ); } $slides_arr[] = $tmp_arr; } }else{ ?>
'; $caption .= '
'; if ( ! empty( $slide['caption'] ) ) $caption .= '

' . $slide['caption'] . '

'; $caption .= $slide_link . '
'; $images .= '' . $slide['alt'] . ''; $i++; } ?>
dt_defaults ); ?>


'dt_slider', 'post_status' => 'publish', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); if( $slides->have_posts() ): if( empty($instance['cats']) ) { $instance['cats'] = $slides->posts[0]->ID; } ?> posts as $slide ): ?> ID == $instance['cats'] ); ?>/>

/>

milliseconds
(1 second = 1000 milliseconds; to disable autoslide leave this field blank or set it to "0")