Hi,
When I uploaded data into custom fields I replaced CrLf with "|" so each row had the correct number of fields in the csv file.
When I display these fields on my site I want to restore the CrLf, so that the text appears correctly. How and where do you recommend I do this - in the wp-loop or the html on the page?
Thanks for your help
David
How and where do you recommend I do this - in the wp-loop or the html on the page?
I don't recommend either of those approaches, I recommend you import the values with embedded line break tags. Otherwise you're going to fight this issue everywhere on the site, or you'll have to use custom code to revert that text replacement after the import. In a WYSIWYG field, you can use a br tag to insert a line break:
First line.<br />Second line.
Then when you use the Types field shortcode to display this field value, the line break will be displayed by the browser. A br tag should not affect the rows and columns in a CSV file.
Thanks Christian, yes you're right of course that's what I should have done, should have asked for advice before uploading the csv file and saved myself alot of extra work. So before I do as you suggest, please could you confirm that these are the steps I need to do - I'm replacing the child posts that have a one-to-many relationship with parents posts.
1. remove the relationships using toolset_disconnect_posts
2. delete the child posts and their taxonomies.
3. replace CrLf with <br /> in the csv file containing the child posts.
4. upload this csv file.
5. download the new post ids
6. create the parent child relationships using toolset_connect_posts
I understand there's probably better ways of doing this, but this is the method I used successfully the 1st time I uploaded these posts, so please could you just let me know if the above steps will work - or if I've missed something
Thanks
David
Do you have a database backup from before the import? If not much else has changed on the site since the backup, you could revert to the database backup and skip all these undo's. If that's not possible, read on:
1. remove the relationships using toolset_disconnect_posts
This step isn't necessary if you delete the child posts via wp-admin.
2. delete the child posts and their taxonomies.
Any reason to delete and recreate/reimport taxonomies? I would just keep and reuse those.
3...4...5...6
Seems like you're adding unnecessary work for yourself. You can consolidate these steps by adding the post relationship information directly to the CSV file as explained here:
https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/
Then upload and import the CSV. After the posts are imported, use the Toolset Import tool to convert those imported relationship values to relationship connections in the Toolset system. No PHP is required.
Hi Christian, Thanks very much for your input, feel I'm finally doing this right.
After I've uploaded the csv file would I see the associations in the Import Associations panel?
I've included a screenshot of part of the csv file, does it look ok to you?
Thanks
David
Two things I can see:
1. Spelling error in the associations column header, you have "associatons" but it should be "associations".
2. I see you are using the numeric post ID instead of the post title. The numeric post ID is not supported here, you should use the GUID instead. You can find the GUID in the database as a column 'guid' in the posts table. It looks like a URL.
If the post relationship slug is "plant-with-complaint-list" then you should see the associations appear in the Import tool Associations panel.
Hi Christian,
Thanks, not sure how to download the GUID. I'm using the "WP All Export" plugin to export fields, there's no GUID there, but I see a field called Permalink - is this the GUID?
Thanks
David
I'm not sure how to use their software, so that's a good question for the WP All Export support team. In the database, there is a column in the post table called "guid", and that's the information you need. It contains a URL, but it might not be the same as the post "permalink" as shown in the post editor screen. The GUID will probably have the post or page ID as a URL parameter instead of the pretty permalink. I'm not sure if their software gives you the GUID from the database as Permalink, or the pretty permalink as Permalink.
You can try with post title if GUID isn't possible. Otherwise, you can download the information from your database as a CSV file, then merge that information with your exported CSV file manually.
Thanks Christian,
WP All Export outputs pretty permalinks, so I tried prefixing "hidden link" to the parent post id - as I understood this was the GUID format - but received error message "Associations can't be imported" 'cause the Parent was missing for all posts.
So I used parent post title and was able to import all the Associations
Thanks for your help
David