
WordPressのサイト内検索は、デフォルトのままだとカスタムタクソノミーの値が検索対象に含まれません。
この検索機能を拡張する便利なプラグインが[Search Everything]ですが、残念なことに、新規投稿の公開時にエラーが発生するバグが残っており、しかも製作者様も放置しているという事態になっています。
出力されるエラー警告はおおむね次のとおり。
Fatal error: Cannot use object of type WP_Error as array in /home/example.com/public_html/wordpress/wp-content/plugins/search-everything/search-everything.php on line 927
どうやらWordPress本体のバージョンとの兼ね合いで起こるエラーのようですが、次の方法で解決できます。
Search Everything(Version: 8.1.9)のエラーの解決方法
プラグイン[Search Everything]の本体ファイル、『search-everything.php』内の913行目以下を、下記のコードで上書きします。
function se_post_publish_ping($post_id) {
$status = false;
if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
$permalink = get_permalink($post_id);
$zemanta_response = se_api(array(
'method' => 'zemanta.post_published_ping',
'current_url' => $permalink,
'post_url' => $permalink,
'post_rid' => '',
'interface' => 'wordpress-se',
'deployment' => 'search-everything',
'format' => 'json'
));
if (!is_wp_error($zemanta_response)) {
$status = json_decode($zemanta_response['body'])->status;
}
}
return $status;
}
add_action('publish_post', 'se_post_publish_ping');
実際に置換するのは、916行目のif( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {と、最末尾、935行目のadd_action('publish_post', 'se_post_publish_ping');の箇所になりますね。
この2カ所を書き換えると正常に動作するはずです。
お困りの方はぜひお役立てください。
Search Everything : https://wordpress.org/plugins/search-everything/