Forum Replies Created
-
AuthorPosts
-
AdditiveFX
Participantperfect! Thanks for your help
AdditiveFX
ParticipantTo be clear, this is the working code:
add_filter('asp_results', 'asp_results_remove_unlinked_attachments'); function asp_results_remove_unlinked_attachments($results) { foreach ($results as $k=>&$r) { if ( isset($r->post_type) && $r->post_type == 'attachment' ) { $parent_id = wp_get_post_parent_id( $r->id ); if ( is_wp_error($parent_id) || empty($parent_id) ) { // Remove the post from the results list unset($results[$k]); } } } return $results; }AdditiveFX
ParticipantHey,
it works now with your proposed fix! The results are indeed of post-type “attachment”. Content type is still “pagepost” for everything. When I print the post-type somewhere I get sensible strings like “attachment”, “event”, “page” and “post”
This is solved. Would be interesting to know why the first solution doesn’t work for me.
I’m using the index table engine, I have several custom post types in WordPress, I have indexed all of them including file contents – Seems like a normal use of your plugin, doesn’t it? 🙂
Btw. this is an awesome plugin! Really happy with it!AdditiveFX
ParticipantI have version 4.14.6, on codecanyon that’s the newest version, right?
AdditiveFX
ParticipantHi,
I have tried this and no luck.I think I know why it is not working: when I return $r->content_type somewhere visible it’s always “pagepost” – never “attachment”
Is there something wrong in my settings?
add_filter('asp_results', 'asp_results_remove_unlinked_attachments'); function asp_results_remove_unlinked_attachments($results) { foreach ($results as $k=>&$r) { $results[$k]->title = $r->content_type; } return $results; }this always returns “pagepost” as the search item title.
AdditiveFX
ParticipantHey, thanks for the speedy reply 🙂
I have implemented this and it doesn’t seem to work :/ Is this supposed to also filter the AJAX results?
Right now there is no difference in the results, do I need to empty some sort of cache in your plugin for the changes to take effect?Thanks!
-
AuthorPosts