Import value in ACF relational fields not as expected

Closed

Import WP Addon - Advanced Custom Fields Updated 1 year ago 11 Replies

Geert asked 1 year ago on November 9, 2023 at 12:52 pm

Hi,

 

I have importWP with ACF addon and xlsx addon and then update my plugin with a custom download you published on a ticket for someone having trouble working with xlsx files, which helped me too.

What I am trying to achieve is to make a website for bible study and upload data trough excel files, mostly into ACF Fields. As I have scripture posts and commentaries and then a lot of related stuff I want to import into taxonomies and ACF relational fields.

That doesn’t work well. I found a respons in the faq pointing towards a snippet, but that only describes date formats where I have bi-directional cross-reference fields. Do you. have a snippet or description on that too?

If you want, you can check my environment. I have imports ready.

 

Best, Geert

 

J

James replied Support Agent

1 year ago on November 9, 2023 at 1:41 pm

Hi Geert

Can you please export and attach your importer settings to this ticket by going to Tools > Import WP > Settings / Tools > Import / Export and select and export your importer as a JSON file.

Can you also export your acf field groups.

And attach the xlsx file being used

James

GK

Geert replied

1 year ago on November 9, 2023 at 2:04 pm

See attachments.

I exported two Importers which I have used for testing purposes and as for ACF some CPT and all field groups.

The field groups are a bit messy at the moment since I am trying to figure out what works best. I was working towards using the same field on multiple places where the value is consisent.

As for cross references, that is field cross_reference

I do also have a link between the field books and taxonomy books, that won't work fine. But is less important.

As for xlsx the kant-import... works as example. For reference I added another containing related information.

J

James replied Support Agent

1 year ago on November 9, 2023 at 10:25 pm

Thanks,

using the "CMT: Kanttekeningen (handelingen)" importer, for the "cross reference" acf field, i updated the value from:

{13}

to:

[iwp_fn_get_posts_by("{13}", "post_title", ""bible-verse")]

This means that it will search the bible-verse custom post type for any titles that match, Result attached importing the first record.

This custom method can be used for other relationship fields by changing the post type and if required changing the field it searches.

I did notice that your importers were importing to drafts, since the post_status field was not enabled / set to publish.

And that your importer has the unique identifier of ID but you are not using the ID field.

For example the "CMT: Kanttekeningen (handelingen)" importer, it looks like you have a Commentary ID as an acf field, so i would use the is the unique identifier by setting the unique identifier to the acf field name: commentaryID, (however i have just noticed a bug in the unique identifier dropdown that i will release a quick patch to fix that if you set a custom value such as commentaryID and then save it, the dropdown appears empty, when it actually has that value saved.)

GK

Geert replied

1 year ago on November 10, 2023 at 2:31 pm

Hi James,

Thank you for this extensive answer. I will test soon. 

You are right with your conclusion about the other points. I was wondering why sometimes new posts get created and sometimes they dont. I created my own unique identfier (Aspicium ID) and imported that into the ID field, but wordpress created posts just with own numbers. But if I am right, I can use the Aspicium ID so that the wordpress ID will be forced with that number? In that case, do they need to be unique per post type, or in general?

About the post field, can I configure that in the importer too? That would help indeed. As you can see I am planning on pushing quite a bit. Luckely just testing now.

Thanks for testing it too. I will let you know my findings.

J

James replied Support Agent

1 year ago on November 10, 2023 at 2:39 pm

There is no way to force a wordpress ID like you mention, but if you have a custom field "Aspicium ID" set to a unqiue value, you can then look in acf and find what the field name is called e.g. "aspiciumID", and set this as the unique identifier, then when it looks to see if it should update or insert it uses this custom field to check. (updating to importwp 2.8.3 should fix the disappearing custom unique identifier value)

If the post field in question is the post_status field, you can enable this via the enable fields button shown at the bottom of the post field section on the importer tempalte.

GK

Geert replied

1 year ago on November 11, 2023 at 10:01 pm

Ok thank you. 

I do have one follow-up question. In my Bible import you see that I append categories on book but basically I make chapters. What I should do is create a Genesis > Genesis 1 structure.

Now I tried to do it with terms as {5} > {6} but that only creates the chapter taxonomy item.

What would be the correct way to do this?

J

James replied Support Agent

1 year ago on November 13, 2023 at 1:23 pm

Hi Geert,

In the taxonomy terms section, did you enable the hierarchy and make sure the hierarcy characterw as set to >

James

GK

Geert replied

1 year ago on November 13, 2023 at 7:14 pm

Hi,

 

Yes, but I have tried different options. See image for how it is now.

J

James replied Support Agent

1 year ago on November 13, 2023 at 7:54 pm

In the screenshot, for example the hierarchy character should just be:

>

And this should create the term

{5} with the child of {6}

GK

Geert replied

1 year ago on November 14, 2023 at 7:32 am

Thanks, this works. It adds the posts to both of the categories now. But that ok.

J

James replied Support Agent

1 year ago on November 20, 2023 at 12:36 pm

Hi Geert,

Just checking in to see how you are getting on with the importer? before i close the ticket.

To help support the plugin i would be very grateful if you could leave a rating/review only if you want to https://wordpress.org/support/plugin/jc-importer/reviews/

James