Skip Navigation

[Resolved] insert cpt content to another cpt content

This support ticket is created 3 years, 9 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 4 replies, has 2 voices.

Last updated by Luo Yang 3 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2003679

hi I have a cpt name A and another cpt B
I will update B everyday for example. discount, price. quality and so on, but B is a part of A,
so. can I insert B when I posting A? so that I don't need to change every post, just need to change the content in CPT B
thanks so much

#2003905

Hello,

Yes, it is possible, you can display post content of "POST A" with shortcode [wpv-post-body], for example:
[wpv-post-body view_template="None" item="123"]

Please replace 123 with post ID of "POST A"

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body

#2003951
截屏2021-03-29 下午2.56.37.png

我可能需要更详细的描述一下我现在的情况 我的cpt b 并没有使用默认的wordpress content, 而是使用了repeater filed , 并且我对b类型文章创建了一个view
使用你给我的短代码 嵌入b到a中 并不能正确的识别到b的相关内容 repeater filed 部分显示并不正常

#2003979

还是不太清楚,文章类型A和B之间有关系(Relationship)吗?
https://toolset.com/course-lesson/how-to-set-up-post-relationships-in-wordpress/
如果有关系,你可以按照我们的文档在“文章类型A”内显示相关的“文章类型B”:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

你也可以提供一个演示站,我上去看看

#2004021

我可以登入你的网站,并做了一下修改:
1)使用classic editor创建一个新view "serversaff-view-2":
hidden link
- 查询“servers aff info”
- 查询过滤器:
从servers aff info组中选择项目that are a related to the current post in the loop.
这里需要使用current post in the loop,因为在别的任意文章内并没有相关“servers aff info”字段组
- 循环编辑器,显示一个简单表格,这里需要你自己做其他设置,我只做一个演示
因为你是做表格显示,所以我推荐用经典编辑器来创建这个view,在blocks编辑器里面,表格有些问题还没有解决

2)创建一个新的content template "serversaff-ct":
hidden link
显示上面的view

3) 创建一篇“任意文章”:
hidden link
显示上面的content template的简码:
[wpv-post-body view_template="serversaff-ct" item="585"]
其中数字585为digital ocean的Post ID:
hidden link

测试结果如下:
hidden link

你看看是不是你想要实现的