I'm using the latest CiviCRM Wordpress version and have imported thousands of contacts and their memberships. The problem is when I attempt to import the associated contributions they seems to be no way to linked the contributions to their memberships. Jon G has answered a similar question (below) but I'm not sure I can use his advise as I have already imported the memberships. Any an all advise welcome.
Bulk Import of Membership Dues - Jon G's Answer
It sounds like your process of importing memberships via CSV and contributions via CSV works - except that your contributions and memberships aren't linked.
If that's correct, I've resolved this when doing migrations as follows:
Create a custom field for contributions called "external serial" or similar. Create a custom field for memberships also called "external serial". Add a serial number column to your CSV (if one doesn't already exist) before importing it as contributions/memberships. The only important part is that each row have a unique identifier. After import, you can use the shared identifier to create a new CSV with just two columns - membership_id and contribution_id (as CiviCRM assigned them). I typically would do this via SQL. Something like this: SELECT cc.id AS contribution_id, cm.id AS membership_id FROM civicrm_contribution cc JOIN civicrm_value_importfieldcc_1 cvi1 ON cc.id = cvi1.entity_id JOIN civicrm_value_importfieldcm_2 cvi2 ON cvi1.external_serial_1 = cvi2.external_serial_2 JOIN civicrm_membership cm ON cvi2.entity_id = cm.id Create membership payments using this new CSV to link the memberships/contributions. You can do that with the API CSV Import GUI extension or the command-line tool that ships with CiviCRM.