0

I have a short-code in my wordpress site in file functions.php I have this short-code

function Insert_NewsBlogsByTags($attr) {
    $a = shortcode_atts(array(
        'title' => 'News',
        'selector' => '#all',
        'number' => 4,
        'tags' => ''
    ), $attr);
    ob_start();
    the_widget(
        'Fbstax_Widget_Recent_Posts_By_Categories_Tags',
        array(
            'title' => esc_html__($a['title'], 'fbstax-theme'),
            'selector' => esc_html__($a['selector'], 'fbstax-theme'),
            'number' => $a['number'],
            'tags' => $a['tags']
        )
    );
    return ob_get_clean();
}
add_shortcode( 'InsertNewsBlogsByTags', 'Insert_NewsBlogsByTags' );

Here I am calling for a widget to display posts by some tags. I am making selection in widget class file like this:

 $r = new WP_Query(apply_filters('widget_posts_args', array(
            'posts_per_page' => $number,
            'no_found_rows' => true,
            'post_status' => 'publish',
            'ignore_sticky_posts' => true,
            'cat' => '20,45',
            'tag_id' => $instance['tags']
        ), $instance ) );

But when I call in it in page builder like this:

[InsertNewsBlogsByTags tags="70, 244"]

It doesn't display anything. Only one tag can be selected. Can you advise how to fix it?

Arebhy Sridaran
  • 586
  • 12
  • 28
zakharov.arthur
  • 187
  • 2
  • 13

0 Answers0