A client's WordPress site looked fine on the home page and on its product pages. Every blog post, though, had two problems: a PHP warning printed at the top, and an empty <h1> . The cause was one line in the theme's single.php .
The symptom
Open any post and you saw:
a PHP warning above the content about accessing an array offset on a value that wasn't an array;
an <h1></h1> with nothing inside it.
The empty H1 is the expensive part. Search engines and screen readers use the H1 as the page's main heading. Every article on the blog was effectively untitled.
The cause
The theme was built for its own custom post type. In single.php the title came from the theme's own data array (simplified):
< h1 ><? php echo $content [ 'title' ] ; ?></ h1 >
Enter fullscreen mode
Exit fullscreen mode
That array is filled for the theme's own content type. On an ordinary blog post it isn't, so $content wasn't an array.…