【WordPressプラグイン:Similar Posts】のカスタマイズ例


Warning: Undefined array key 1 in /home/realine/realine.me/public_html/wp-content/themes/cocoon-child-master/functions.php on line 31

Warning: Undefined array key 3 in /home/realine/realine.me/public_html/wp-content/themes/cocoon-child-master/functions.php on line 36

Warning: Undefined array key 5 in /home/realine/realine.me/public_html/wp-content/themes/cocoon-child-master/functions.php on line 41

Similar Postsで関連記事を表示させた際に「Notice: Undefined variable: res in (ファイル名) on line (行数)」が表示された際の解決方法

SimilarPostsのエラー画面

Similar Postsで関連記事を表示させた際に該当する記事が0件の場合に「Notice: Undefined variable: res in (ファイル名) on line (行数)」と表示される事が稀にあります。

私の場合は常時SSL化(https)を行った際に表示されました。この解決方法を紹介します。

記載日:2017/5/11

対象テンプレート名:similar-posts.php

  1. プラグイン>編集>Similar Posts>similar-posts/similar-posts.phpを開いて該当行数を確認すると恐らく以下のコードになっていると思います。
    return $res;
  2. 上記のコードになっていた場合は、上記コード上に以下コードを追加します。
    $res = NULL;
  3. 実際に変更すると以下コードとなります。
    $res = NULL;
    return $res;
  4. 「ファイルを更新」で編集完了後に正常に表示されているか確認できれば完了です。

 

タイトルとURLをコピーしました