Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › List only publishers items
This topic contains 3 replies, has 2 voices, and was last updated by msamavi64 1 year ago.
- AuthorPosts
- February 28, 2022 at 5:37 pm #36941
Hello,
I am using the Index Table engine that indexes all types of posts with any status (publish, draft, private, …).
I have two search instances: [wd_asp id=1] and [wd_asp id=2]
I want to use the first instance on the front page for customers that need to list only products with the status “Published”.
I want to use the second search instance on the backend to admin and shot manager use that needs to list any post type with any status.Can you provide any snippet for the first search instance so as to limit its listing to published posts, please?
Thanks and regards,
MajidMarch 1, 2022 at 12:46 pm #36953Hi Majid,
Based on your description, I recommend trying this custom code:
Best,add_filter( 'asp_results', 'asp_hide_by_status', 10, 2 ); function asp_hide_by_status( $results, $search_id ) { foreach ($results as $k=>$r) { if ( isset($r->post_type) ) { if ( $search_id == 1 && get_post_status($r->id) != 'publish' ) { unset($results[$k]); } } } return $results; }
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 1, 2022 at 12:50 pm #36955Hi,
Thank you.
Can you limit the results for the first instance [wd_asp id=1] to WooCommerce Products and LearnDash Courses, please?Kind regards,
MajidMarch 1, 2022 at 1:18 pm #36963Hi,
In my initial tests, all seems working perfectly.
Doing more testsRegards,
Majid - AuthorPosts
You must be logged in to reply to this topic.