• I used that plugin and it works fine but recently, I saw that always show me the File Attachments at the final on my post even if the post had (only) a title and a few words into the content.

    That is a example. I tried to remove it from the admin but is impossible, always appear again.

    What could be the reason?

Viewing 1 replies (of 1 total)
  • For anyone looking for a solution, I’ve written this code to make sure empty attachments aren’t added to the database.

    add_filter('sanitize_post_meta__wppcp_post_attachments', 'sanitize_wp_private_content', 10, 3);
    function sanitize_wp_private_content($meta_value, $meta_key, $meta_type) {
        // avoid infinite recursion
        remove_filter( current_filter(), __FUNCTION__ );
    
        // clean meta value array
        $new_meta = array();
        foreach( $meta_value as $key => $attachment ) {
            if( $attachment['attach_id'] && $attachment['attach_id'] > 0 ) {
                $new_meta[$key] = $attachment;
            }
        }
    
        return $new_meta;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Always show file attachments in my post’ is closed to new replies.