[ad_1]
I have a Shortcode with multiple parameters , like this
function recentpost_shortcode($atts, $content = null) {
global $post;
extract(shortcode_atts(array(
'post_type' => '',
'headline_get' => '',
'cat' => '',
'style' => '',
'num' => '5',
'order' => 'DESC',
'orderby' => 'date',
), $atts));
$args = array(
'post_type' => $post_type,
'cat' => $cat,
'posts_per_page' => $num,
'order' => $order,
'orderby' => $orderby,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
$output="";
$posts = get_posts($args);
$output .='<ul>';
foreach($posts as $post) {
setup_postdata($post);
$output .='<li>'.esc_attr( get_the_title() ).'</li>';
}
$output .='</ul>';
wp_reset_postdata();
return $output;
}
add_shortcode('recentpost', 'recentpost_shortcode');
It is for displaying articles on the site
And I want to turn it into a widget
Is this possible and how?
Thanks
[ad_2]