Hi @josselynj
Well, yes. The PDF content is indexed under cluster “attachments_content”. You can set up cluster weights in the WPFTS Settings / Search & Output / Relevance. For example, set up 0.1 for attachments_content and see what happen.
Hi
It seems to work better thanks
Also, is it possible to exclude some type of post ?
Example, i’ve some CPT named “evenements” and i don’t want to list them in the search results.
Is it possible ?
Hi, @josselynj
Actually you can use standard WP_Query’s hook to filter search by post_type.
Here is a sample code that you can use
add_action('pre_get_posts', function(&$wpq)
{
if ($wpq->is_search && $wpq->is_main_query()) {
$wpq->set('post_type', array('page', 'post', 'attachment')); // Add more post_types here
$wpq->set('post_status', array('publish', 'inherit'));
}
});
You need to place this code to the functions.php of your theme or child theme. Also you could add more post types to the 4th line (see comment).
You can see there are page and post already as well as attachment for media files. So evenements will not be searched on for this case.
Please let me know if it works. Thanks!
-
This reply was modified 1 year, 11 months ago by
Epsiloncool.
Hi
yes it works thanks but it’s for ALL the CPT’s on the website right ?
Not only for the CPT “evenements”
It should be ok at the moment since we don’t have others CPT
Yes, this is “whitelist” method. You can add any CPTs to the list which you need to be searched on.
You can change this method to the “blacklist” if you need. To do that you can change the line 4 to
$wpq->set('post_type__not_in', array('evenements')); // Add more post_types to exclude here
Again, this is a native WP_Query thing, you can read more here.
Thanks!