How to get widget content in WordPress based on it’s ID?


I need to parse widget content based on it’s ID.

But a widget works like a function that pulls data based on it’s arguments, right? So when I pull the widget data, I can only get it’s arguments, not the actual output.

How can I parse the widget content based on it’s ID?

Example code:

// Update widget rounds automatically
function automatize_games_rounds($instance, $widget, $args){
    // Check if there is a caption
    if (isset($instance['caption']) && !empty($instance['caption'])) {
        // If there is, does it contain the word "round"?
        if (strpos(strtolower($instance['caption']), 'round')) {
            // If yes, it's the kind of widget I'm looking for. Let's get it's ID.
            $id = $args['widget_id'];
            // Now I need to parse the widget output to do some stuff based on it's content, but how can I get the widget output?
    return $instance;


>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="">

How to get widget content in Wordpress based on it's ID?</a>
, , Lucas Bustamante 7 months 0 Answers 111 views 0

Leave an answer