Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Restrict Index Table based Search to search only in PDFs in Working Papers
This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko 2 years, 10 months ago.
- AuthorPosts
- June 8, 2021 at 6:42 pm #33564
We have four CPTs: JWE-Issues, JWE-Articles, JWE-Reviews and Working Papers. Some of them with PDFs attached. All 265 Working Papers have one PDF each. I built the Index Table and a search in Working Papers to search ONLY! in the PDF content. It is working but the results are showing PDFs from other CPTs too. I tried a lot of different settings but i am not able to restrict the search to search only in the content of the Working Paper PDFs.
In general: Is that posibble and of so, where do i find the correct setting?
Thanks in advance. I tried a lot of different search plugins. Yours is by far the very best.
Link to the page:
https://wine-economics.org/working-paper-test/June 9, 2021 at 8:07 pm #33583Hi,
Thank you very much for your kind words!
Unfortunately this is not possible I’m afraid. I can try suggesting a custom coded solution, but it may not work in all cases, or at all.
add_filter('asp_results', 'asp_remove_attachments_by_cpt', 10, 1); function asp_remove_attachments_by_cpt($results) { foreach ( $results as $k => &$r ) { if ( $r->content_type == 'attachment' ) { $p = get_post(wp_get_post_parent_id($r->id)); if ( $p->post_type != 'working_paper' ) { unset($results[$k]); } } } return results; }
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 11, 2021 at 5:58 pm #33623Hello Ernest
Thank you for your response.
The codeyou provided doesn’t work.
I will try to find other setting.Cheers
Ralf
June 14, 2021 at 7:55 am #33636All right, I am not sure why it does not work though.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
You must be logged in to reply to this topic.