We have a Wordpress intranet using BuddyPress, bbPress etc..
From this article, I adjusted my theme's searchform.php
to include:
<input type="hidden" name="post_type[]" value="docs" />
<input type="hidden" name="post_type[]" value="events" />
<input type="hidden" name="post_type[]" value="forums" />
<input type="hidden" name="post_type[]" value="posts" />
<input type="hidden" name="post_type[]" value="pages" />
<input type="hidden" name="post_type[]" value="topics" />
However, when we search for content written inside a Wordpress page, the search does not find this content.
This fact makes me wonder if the search is working properly or not.
The search results page reaches a URL like:
www.example.com/?post_type%5B%5D=docs&post_type%5B%5D=events&post_type%5B%5D=forums&post_type%5B%5D=posts&post_type%5B%5D=pages&post_type%5B%5D=topics&post_type%5B%5D=doc&s=document
I have tried including singular and plural but the issue remains:
<input type="hidden" name="post_type[]" value="docs" />
<input type="hidden" name="post_type[]" value="events" />
<input type="hidden" name="post_type[]" value="forums" />
<input type="hidden" name="post_type[]" value="posts" />
<input type="hidden" name="post_type[]" value="pages" />
<input type="hidden" name="post_type[]" value="topics" />
<input type="hidden" name="post_type[]" value="doc" />
<input type="hidden" name="post_type[]" value="event" />
<input type="hidden" name="post_type[]" value="forum" />
<input type="hidden" name="post_type[]" value="post" />
<input type="hidden" name="post_type[]" value="page" />
<input type="hidden" name="post_type[]" value="topic" />
Confused.
Help appreciated.
Update:
If I add
add_action( 'admin_footer', function() { print_r( get_post_types( [ 'exclude_from_search' => true ] ) ); } );
to functions.php
, I receive the output:
Array
(
[revision] => revision
[nav_menu_item] => nav_menu_item
[custom_css] => custom_css
[customize_changeset] => customize_changeset
[wp_router_page] => wp_router_page
[forum] => forum
[topic] => topic
[reply] => reply
[buddydrive-file] => buddydrive-file
[buddydrive-folder] => buddydrive-folder
[bp-email] => bp-email
[bp_docs_folder] => bp_docs_folder
[vc_grid_item] => vc_grid_item
[bwg_gallery] => bwg_gallery
[bwg_album] => bwg_album
[bwg_tag] => bwg_tag
[bwg_share] => bwg_share
[tribe_venue] => tribe_venue
[tribe_organizer] => tribe_organizer
[deleted_event] => deleted_event
[rtmedia_album] => rtmedia_album
[thrive] => thrive
)
post
andpage
are the built-in post types- singular, not plural.