I uploaded some attachments with title and description. How to make the search function on front page to search these attachments?
I uploaded some attachments with title and description. How to make the search function on front page to search these attachments?
I tried "search-everything", it does not work for search the description of the files in Media. I think it need to hack the codes of WP, make the searching include not only post_type="page" and "post", but also "attachment". Who knows how to do it? Thanks.
In order to query for attachments you'd need to set post_status to inherit or any... (using "any", drafts etc.. will show up)..
How to change the post_status by default? I want the post_status will be "any" when a user adds a file into Media. Thank you!
I think you're missing the point, if you query for any, you'll also end up with Drafts and Revisions, etc... in the results..
How to do it? In "Search" function, no options. Or I need add an entry in config file? Thank you!
I would also like to be able to include the attachment description when searching, this doesn't seem doable with the 'Search Everything' plugin. Don't get that stuff about setting something to 'any', what do you mean?
The search query, by default is set to post, if you add a query arg into the query posts line of your search.php, you can do any number of things..
if(!$wp_query) global $wp_query;
$args = array(
'post_type' => 'any',
'category' => 3,
'author' => 1
);
query_posts( array_merge( $args , $wp_query->query ) );
There's a few example args in the above... ;)
Again, i'll repeat, if you use "any" you'll also get Drafts and Revisions, amongst other things in the result set.
Attachments, should you want to query for them specifically, have a post_type of inherit. The actual post type is inheritted from the attachments parent, which is usally the post it has been attached/inserted into, if one exists...
You must log in to post.