Skip Navigation

[Resolved] Issue with related posts not working anymore

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a Form used to create child posts. On a parent post, I have inserted a Create Child Post Link, linking to the new child post Form. In the past, the parent post was automatically associated with the child post. Now, the child post is created but not associated with the parent.

Solution: Add a post relationship field to the new child post form and set the value using the same URL parameter used in your Create Child Post Link URL. Add some CSS to a wrapping div element to hide the field.

<div style="display:none;">[cred_field field='@ob-exhibitor_brand.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' urlparam='parent_ob-exhibitor_id']</div>
This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1325167

I have 2 CPTs setup. Exhibitor CPT has Brand CPT as a child.

I have a page which has a button where they can add a new brand and link it to the exhibitor using the cred_child_link_form shortcode [cred_child_link_form form="2872" parent_id="-1" text="Create new brand" target="_self"]

This was working but has stopped at some point over the last few months. I've noticed in the database, the ones that work have a entry in post_meta _wpcf_belongs_ob-exhibitor_id

What would I need to do to fix?

#1325207

Hi, please tell me a bit more about your setup.
- Have you migrated to the new post relationships system? If not, you would see a message about migration in the Toolset > Relationships dashboard. If so, you would see a list of Relationships appear there.
- In the page where the create child link should appear, is the link in a View or Archive of Exhibitors, or is the link in the single Exhibitor page template?

Also you mentioned that it stopped working. Please let me know more specifically what is happening.
- Does the create child link appear on the page?
- Does the link lead to the wrong destination when clicked?
- What URL does the link lead to?
- Does the link lead to a Form that doesn't work?
- Does the Form create content but not connect it in the post relationship as expected?

#1325243

Yes, I ran the migrate option which completed successfully but no change.

The create child link is shown in a view of exhibitors which has the option 'Post author is the same as the logged in user' selected.

The URL links to a page with another view which shows the brand CRED edit form. This form works and I can add a brand but it does not create the post relationship.

I can give you access to a staging site if that would help?

#1325251

Yes I think that would be helpful. Please provide login credentials here in the private reply fields and let me know where I can find the View of Exhibitors on the front-end of the site. If this User is not an admin User, I will probably need an admin login as well so I can check out the setup in wp-admin.

#1325327

Hi, I was able to log in to the Exhibitor Zone using the credentials you provided, but I don't see Exhibitor details or Brand details and I'm not quite sure where to start adding those. Should I create the Exhibitor post first in wp-admin?

#1325343

I've added an exhibitor to the admin login so you can see the link on the front end here

#1325351
Screen Shot 2019-08-27 at 12.00.39 PM.png
Screen Shot 2019-08-27 at 12.00.17 PM.png

Okay I think I have it working now. The problem is that in older versions of CRED, it was sufficient to use the parent post ID in a URL parameter to set the relationship automatically. Now, the URL isn't sufficient. You must also use a post relationship field in the Form Editor. Normally the Form Builder will generate this field automatically when you create a Form, but in this case your Form already existed. I'm attaching screenshots here showing how I added the relationship field. Then, since you don't want to display this field to your clients, I added some CSS to a wrapping div to hide it. Here is the final code:

<div style="display:none;">[cred_field field='@ob-exhibitor_brand.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' urlparam='parent_ob-exhibitor_id']</div>

Check and let me know if the problem is not resolved.

#1325397

Yes, working well thank you! I appreciate you sorting that and for the clear instructions 🙂