• MACscr

    (@macscr)


    How can i get the widget id for the widget_text filter so that I can only apply it to a particular widget instance? Id like to do something like so:

    add_filter('widget_text', 'rotate_video_shortcodes');
    function rotate_video_shortcodes($text) {
    
        if ($widget_id == 5) {
            $videos = explode(',', $text);
            shuffle($videos);
            foreach ($videos as $video) {
                do_shortcode('[ytp_video source="'.$video.'"]');
            }
        }else{
            return $text;
        }
    }
  • The topic ‘get widget id for widget_text filter’ is closed to new replies.