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
- What is the difference between $paged and $page?
- multi page password protection
- Create a “Dummy” parent page for a hierarchy in page listing?
- Custom SQL Query for WordPress page
- Change admin startpage to Pages-page?
- Search with filters and title
- How restrict page for users logged? [closed]
- Only allow new subpages to be created
- How to limit search to first letter of title?
- Hide Visibility Option From WordPress Publish Metabox
- WordPress 4 and wp_editor() Not Showing Visual/Text tabs
- How to make nested page structure?
- Redirect to a page if ancestors is empty
- Get Order of Meta Box in a Page/Post
- Check to see if page exists problems
- Modify Page Title before output via wp_page_list
- Custom /page/2/ template (different from index.php)
- Adding id and class to the search input in WordPress search form
- Front Page not showing on Pages
- WordPress pages with hierarchy
- Hiding Page by Title from Editing
- Why doesnt ONE of my links in the footer work properly? [closed]
- Use lots of pages, or categories/posts?
- How to have custom tinyMCE buttons break onto next line when too long
- Get all pages that are published
- Add a predefined page to site
- How do i change page template in bulk?
- Determine page content based on page parent
- Make parts of your wordpress website completely built with data from external APIs?
- Weird issue with is_pages() with array
- Missing ‘Page Attributes’ in page edit
- How to show the root webpage on all subpaths
- Could be a namespace conflict (?) with login form and register form on the same page
- The concept of non-blog content
- Loading Multiple Comments Pages via Ajax?
- Change base URL of pages created by certain users
- Remove Content edit box from ALL pages (not posts)
- What is full URL for a post?
- How to create a page and display only the posts with a specific custom field value?
- Remove comment section from new page
- WordPress pages not working out correctly with HTML
- Manage content on multiple pages synchronysly?
- Print page content with formatting when doing custom SQL query
- wp_nav_menu: output featured image of each page listing
- Prompting for review / reapproval of page content
- Limit the amount of main pages
- Add separate list of pages under Admin
- How to transfer a site to hosting?
- How to list pages from an author?
- Add the same content to multiple pages
- Modify WordPress search behaviour in backend?
- Re-order search results with posts_orderby filter and post meta value
- Cannot update page – with too many characters?
- Share a folder with files
- Front Page post mirroring revisions to other pages, constantly updating itself
- Microsoft Security Essentials is blocking my WordPress website in IE11
- Author information on all pages
- WordPress Pages “allow comments” meta option can’t be checked
- Add role and edit page capabilities
- Add text to the bottom of particular pages
- Access wordpress pages using a self signed shared ssl
- WordPress, page 2 shows the same posts as page 1
- How to exclude page in pages module
- get id custom tables on current page
- Create a new page for each form selection
- pagination does not work with query_posts. Help! [duplicate]
- Subpage Conditional
- How to pass the Querystring in pages?
- I have over 3000 child pages – but I need a different main page
- How to make a conditional statement that checks if the page is the child of a certain page?
- Edit the text location of a form
- Why is a page shown with ‘hidden’ next to the name in the list of pages if the page is set to public?