I am trying to help a small business with their Wordpress site but am unable to figure out why their site is generating this error. Here are the details:
The error is this: Undefined offset: -1 in /home/sojour15/public_html/wp-includes/post-template.php on line 278
And here's the code from the post-template.php - starting with line 275 - line 278 is "$content = $pages[$page - 1];"
if ( $page > count( $pages ) ) // if the requested page doesn't exist
$page = count( $pages ); // give them the highest numbered page that DOES exist
$content = $pages[$page - 1];
if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
$content = explode( $matches[0], $content, 2 );
if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) )
$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
$has_teaser = true;
} else {
$content = array( $content );
}
I have read some about undefined offset errors and understand that this means that the code is referring to something in an array that doesn't exist but I am not a PHP coder - just someone trying to help a small business - and I'm not sure how to fix this. I tried a hack I found somewhere - just put an '@' in front of line 278. Weirdly, this hack worked for about a week. Now it's not working anymore - and it would be better to properly fix the code anyway. Any guidance would be very welcome. Thanks. Here also is a link to one of the pages where this happens: https://www.sojournacupuncture.com/treatments-and-services/