We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pages assigned the 404 template should not be appearing in front-end search results.
The text was updated successfully, but these errors were encountered:
Something like this:
function omit404s($query) { if ($query->is_search && !is_admin()) { $args = [ "posts_per_page" => -1, "post_type" => "page", "meta_query" => [ [ "key" => "_wp_page_template", "value" => "404.php", ], ], ]; $templateQuery = new \WP_Query($args); $omitIDs = wp_list_pluck($templateQuery->posts, "ID"); $query->set("post__not_in", $omitIDs); } return $query; } add_filter("pre_get_posts", "omit404s");
Does the name of a plugin-injected template match the file in the plugin or is that something we get to set? ref: #16
Sorry, something went wrong.
joemaller
No branches or pull requests
Pages assigned the 404 template should not be appearing in front-end search results.
The text was updated successfully, but these errors were encountered: