'kp-article-list-widget', 'description' => __('Article list widget', 'ad-mag-lite'));
$control_ops = array('width' => 'auto', 'height' => 'auto');
parent::__construct('Ad_Mag_Lite_Articles_List', __('(AdMag) Article List', 'ad-mag-lite'), $widget_ops, $control_ops);
}
function widget($args, $instance) {
extract( $args );
if ( isset( $instance['title'] ) ) {
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
}
if ( isset( $instance['style'] ) ) {
$style = $instance['style'];
} else {
$style = 'style_2';
}
if ( isset( $instance['excerpt_length'] ) ) {
$limit = $instance['excerpt_length'];
}
if ( isset( $instance['url'] ) ) {
$url = $instance['url'];
}
$query_args = array(
'post_type' => 'post',
);
if ( isset( $instance['number'] ) ) {
$query_args['posts_per_page'] = $instance['number'];
}
if ( isset( $instance['order'] ) ) {
$query_args['order'] = $instance['order'] == 'ASC' ? 'ASC' : 'DESC';
}
if ( isset( $instance['orderby'] ) ) {
$query_args['orderby'] = $instance['orderby'];
}
if( isset( $instance['categories'] ) && empty($instance['categories'] ) ) {
$query_args['ignore_sticky_posts'] = true;
}
if ( isset( $instance['categories'] ) && $instance['categories'] ) {
$query_args['tax_query'][] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $instance['categories'],
);
}
if ( isset( $instance['tags'] ) && $instance['tags'] ) {
$query_args['tax_query'][] = array(
'taxonomy' => 'post_tag',
'field' => 'term_id',
'terms' => $instance['tags'],
);
}
if ( isset( $query_args['tax_query'] ) &&
count( $query_args['tax_query'] ) === 2 ) {
$query_args['tax_query']['relation'] = $instance['relation'];
}
$article = new WP_Query( $query_args );
$num_post = count($article->posts);
?>
have_posts() ) : while( $article->have_posts() ) : $article->the_post() ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
if(!empty($url)){
echo '
'.__('view more', 'ad-mag-lite').'';
}
echo '';
}
}
$count++;
$stt++;
?>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts() ) : while( $article->have_posts() ) : $article->the_post() ?>
-
have_posts() ) : while( $article->have_posts() ) : $article->the_post(); $index++; ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
have_posts()) : while($articles->have_posts()) : $articles->the_post(); $id_post = get_the_id(); ?>
-
|
have_posts()) : ?>
have_posts()) : $articles_sub->the_post(); ?>
>
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); ?>
-
have_posts()) : while($article->have_posts()) : $article->the_post(); $icon = get_post_format(); ?>
have_posts()) : while($article->have_posts()) : $article->the_post(); $icon = get_post_format(); ?>
have_posts()) : while($article->have_posts()) : $article->the_post(); $icon = get_post_format(); ?>
have_posts()) : while($article->have_posts()) : $article->the_post(); $icon = get_post_format(); ?>
have_posts()) : while($article->have_posts()) : $article->the_post(); $icon = get_post_format(); ?>
';
$next = false;
}
?>
';
}
}
$count++;
?>
'',
'categories' => array(),
'relation' => 'OR',
'tags' => array(),
'order' => 'DESC',
'orderby' => 'rand',
'number' => 5,
'posts_per_page' => 4,
'excerpt_length' => 10,
'style' => 'style_1',
'url' => '#',
);
$instance = wp_parse_args((array) $instance, $default);
$title = strip_tags($instance['title']);
$form['categories'] = $instance['categories'];
$form['relation'] = esc_attr($instance['relation']);
$form['tags'] = $instance['tags'];
$form['order'] = $instance['order'];
$form['orderby'] = $instance['orderby'];
$form['number'] = (int)$instance['number'];
$form['excerpt_length'] = (int)$instance['excerpt_length'];
$form['style'] = $instance['style'];
$form['posts_per_page'] = $instance['posts_per_page'];
$form['url'] = $instance['url'];
?>