Why wordpress popular post widget shows Undefined index?

This notice appears when you try to access an undefined index of an array.

To fix this, you’ll need to check if the index exists before you access it. For this you can use isset() or array_key_exists():

I’d need to see the exact line of code that the notice is referring to (line 26) in order to provide you with an an exact answer to your code. Here’s a general example:

// Options 1: isset()
$value = isset($array['my_index']) ? $array['my_index'] : '';
// Options 2: array_key_exists()
$value = array_key_exists('my_index', $array) ? $array['my_index'] : '';