you can use pre_get_posts
filter hook and set the post__not_in
parameter of the query ex:
function exclude_from_search_filter($query) {
if ( !$query->is_admin && $query->is_search) {
$query->set('post__not_in', array(40, 9) ); // id of page or post
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_from_search_filter' );
Related Posts:
- Replace Dashes Before Title in Page List
- Manual excerpts for pages not working on Search
- Custom Search Page Pagination Not Working
- Is there a way to remove or hide individual pages on the Edit Pages screen?
- When I split a large post with , how can a search locate users to the correct page?
- Form action redirect to the same page
- Two Search pages, One search form
- Create subpage – filter parent pages list
- How get get list of pages in ajax search
- Getting to a specific page on website using specific code instead of navigation bar
- Any Ideas for Including “More Tag” with get_pages($args)?
- Can I change the “Home” text in the menu?
- Search child pages from a specific page parent
- create 2 custom columns in page edit in Admin panel
- Search results to be only posts & children of page ID
- Search anything from a Child and Sub-Pages of their Parent page
- Add pagination to search.php page
- Search Page: activate html code if the tag is on the page
- Display child pages on homepage template
- Custom Filter using meta_value in wordpress admin list not working
- If searched in a category show different 404 page
- Search page different title per results
- search page different results
- page wordpress add extra unwanted stuff
- simple category search form returns full text – but I need excerpts
- Adding a filter to wp_edit_posts_query() to prevent hierarchical display of pages
- How to enable automatic search results in WordPress
- Save search criteria per user and show on custom user page
- Search page doesn’t recognise post_type=page
- Search Result to Link to a Specific Page
- Add infinite scroll to content splitted post
- Check if wp-login is current page
- How to get current page ID outside the loop?
- Contact Form on WordPress Sites?
- Page returns 404 with POST variables, but not without
- Custom templates not showing up in template dropdown
- Get page id by template
- Using pre_get_posts on true pages and static front pages
- Get the content of a specific page (by ID)
- How to get page title with the page ID?
- Show more than 20 items in pages or posts edit dashboard
- Allowing user to edit only certain pages
- How to display last 3 posts (recent posts) in a static page?
- How to give paged links custom title?
- How to set post slug when using wp_insert_post();?
- How can I keep the content of my pages version controlled?
- How to load javascript on custom page template?
- How to configure WordPress to handle 75,000 pages?
- How to update page status from publish to draft and draft to publish
- Check if is on child-page of a particular page
- Change page template programmatically ?
- Conditional tag to check if ‘page.php’ is being used?
- Customizing the URLs of WordPress Login and Sign-up Pages?
- Apply the_title() filter in post & page title, but not in menu title
- How to disable posts and use pages only
- Searching multiple custom post types and pages
- featured image as background image on pages
- Check IF is a “single product page” and Check the “role” for a Redirect
- A check for if is parent page, if has children, if has grandchildren
- How to load JS and CSS only on specific Pages using is_page()?
- Listing pages which uses specific template [duplicate]
- Proper way to get page content
- Access the same page from multiple urls (wildcard)
- Create a page without adding a page in the Database
- Is there a way to change the default page template selection?
- Can I have two child pages of different parents with the same name?
- What methods to use to create small, editable pieces of text for static pages?
- Show Default Editor on Blog Page ( Administration Panel )
- Hide page visual editor if certain template is selected?
- What is the difference between $paged and $page?
- multi page password protection
- Create a “Dummy” parent page for a hierarchy in page listing?
- How do I convert a page’s title to lower case?
- Get top level page parent title
- Custom search filter causes menu and query_posts problems
- How to add a specific widget to only 1 page?
- Restrict admin access to certain pages for certain users
- page title, parent tilte and grand parent title
- How to add jQuery script to an individual page?
- WordPress page edit does not save selected template
- Add a Page without header and menus?
- What is an alternative to get_page_by_title()?
- Password protect page with multiple passwords
- Create pages automatically if they don’t exist
- Find empty pages or pages which have less than x characters
- Allow only new sub-pages to be created
- Set page template automatically based on parent
- Editing Complex Pages in Visual Mode
- Link section within page with slash (/) and not hash (#) without reloading the page
- Creating a template using a specific slug name, for a page with a parent page
- Can I display submenus in groups, using wp_list_pages?
- Is there a default template file for child pages / subpages?
- Get wp_get_attachment_url outside of loop
- Order by menu_order and title?
- Require title for pages
- WP Page and Subdirectory with same name
- Filter the query ONLY for the search results page
- Add a new page to wordpress programmatically
- Get Permalink for the top level parent of child pages
- Proper method to restrict non logged users into certain pages