Skip Navigation

[Resolved] relationship can not be inherited from parent posts to child posts

This support ticket is created 5 years, 11 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1181038

I am trying to create a 1on 1 relationship between two post types, also trying to create new child posts by the Create child post link by "Set the parent according to the currently displayed content"
I got two issues
1. since I set the relationship as 1 on 1, I think that 1 parent post has one child post only, but I can add new posts again
2. except connecting the existing relationship post from the backend manually, I submitted posts cannot be connected with the parent post created. that means the relationship can't be passed through URL?

Last time, I wanted to use chat online, so didn't provide access information, just take this ticket please and ignore that ticket I just posted https://toolset.com/forums/topic/parent-relationship-can-not-inherited-according-to-url/

please see the
hidden link to submit a parent post
you can see the child form here hidden link

also, you can check the parent and child post types here from back-end

hidden link parent post type

hidden link child post type.

hidden link relationship setting

#1181296

你好,

感谢你提供的详细信息,我可以登录上你的网站,吃完午饭以后回来回复你,对于这样的在线约课系统,我觉得你的网站设置不是太合理。

#1181298

好的 谢谢回复,我是想要跟Learndash连在一起,learndadh没有约课系统,所以我做一个 这个是从你们的Demo里面抄来的,只是随便放在页面上 主要是看看能不能取到用户信息,之后可能要做一些其他的工作----比如根据个人资料页的国家时差显示不同的时间等等。最后还要跟Event calendar 连到一起, 这个我看到Toolset系统可以实现,论坛里有先例。如果你有什么建议,麻烦告诉我 非常感谢!?

#1181345

1) 关于第一个问题“ I think that 1 parent post has one child post only, but I can add new posts again”, Toolset 子文章表单,是用于One-to-Many关系的, 参考我们的文档:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

它并不能对限制One-to-One关系做限制,你在可以添加一个feature request:
https://toolset.com/forums/forum/professional-support/#feature-request

目前有个变通的办法,你可以添加一个view:
- 查询“1on1”文章
- 限制和偏移:
显示1篇项目
- 查询过滤器:
选择一对一课程组 上课人组关系中的文章that are related to the Post where this View is shown.
- "循环编辑器"
在简码[wpv-no-items-found] ... [/wpv-no-items-found]显示子表单链接,比如

	[wpv-no-items-found]
		<p>[cred_child_link_form form='36' parent_id='-1' text='去预约' target='_self' class='btn btn-primary']</p>
	[/wpv-no-items-found]

参考:
hidden link

然后将上面的view放到“上课人组”模板上:
hidden link
你可以在这里测试:
hidden link
如果没有子项目,则显示“去预约”按钮,如果有子项目,则像是子项目。

2) 关于第二个问题“ the relationship can't be passed through URL”, 这个是你设置的表单有问题:
hidden link
你需要添加一个parent selector field, 比如:

		<label>一对一课程</label>
		[cred_field field='@1o1-scheduler.parent' class='form-control' output='bootstrap' select_text='--- 未设置 ---']

然后再测试,比如打开页面:
hidden link
点击“去预约”按钮,转到页面
hidden link
你应该可以看到“测试预约1”已经被选中,然后你可以通过CSS代码将这个parent selector隐藏掉,用户提交给表单,可以正常保存文章之间的关系。

参考我们的文档:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/