サーバーのphpのバージョンアップ
ここでは割愛しますが、サーバーも常にphpのバージョンをアップしていきます。
wordpressを利用していたら、これにきちんと追いついていかないとエラーが発生します。
今回のエラー
このようなエラーが吐き出されます
Warning: count(): Parameter must be an array or an object that implements Countable in …(ファイルパス)/wp-includes/post-template.php
対処法
該当のファイルを開く
今回はここ
Warning: count(): Parameter must be an array or an object that implements Countable in …(ファイルパス)/wp-includes/post-template.php
この箇所を・・
<br />
// If post password required and it doesn't match the cookie.<br />
if ( post_password_required( $post ) )<br />
return get_the_password_form( $post );</p>
<p> if ( $page > count( $pages ) ) // if the requested page doesn't exist<br />
$page = count( $pages ); // give them the highest numbered page that DOES exist<br />
このように修正します。
<br />
// If post password required and it doesn't match the cookie.<br />
if ( post_password_required( $post ) )<br />
return get_the_password_form( $post );<br />
if ( ! empty( $pages ) ) {<br />
if ( $page > count( $pages ) ) // if the requested page doesn't exist<br />
$page = count( $pages ); // give them the highest numbered page that DOES exist</p>
<p> } else {<br />
$page = 0;<br />
}<br />
終わりに
急なエラーも焦らず、きちんとバックアップを取りながら進めましょう。