- 外観>テーマエディタ
- テーマのための関数(functions.php)に以下の記述を追加
function search_pre_get_posts( $query ) {
if ( $query->is_search && !is_admin() ){
$query->set( 'post__not_in', array(n1,n2) ); // ここに除外したい記事IDをいれる
}
return $query;
}
add_action( 'pre_get_posts', 'search_pre_get_posts' );