esc_html__( 'Your gallery of images from your posts', 'adena'), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// Get Data
$title = apply_filters( 'widget_title', $instance['title'] );
$orderby = $instance[ 'order_by' ];
$order = $instance[ 'order' ];
$html = '';
// Query
$args = array (
'post_status' => array( 'publish' ),
'nopaging' => false,
'posts_per_page' => 6,
'ignore_sticky_posts' => true,
'order' => $order,
'orderby' => $orderby,
);
$q = new WP_Query( $args );
if ( $q->have_posts() ) { // IF HAVE_POSTS
$html .= '
';
} // IF HAVE_POSTS
// Restore original Post Data
wp_reset_postdata();
un_echo( $html, 'html');
}
// Widget Backend
public function form( $instance ) {
// Set Title
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}else {
$title = esc_html__( 'Post Gallery', 'adena');
}
// Set Order By
if ( isset( $instance[ 'order_by' ] ) ) {
$orderby = $instance[ 'order_by' ];
}else {
$orderby = 'date';
}
// Set Order
if ( isset( $instance[ 'order' ] ) ) {
$order = $instance[ 'order' ];
}else {
$order = 'DESC';
}
?>