Problem: I'm trying using the Post Relationship panel of the Custom Post Type editor to connect to an existing standard Post, but I see the titles of another Custom Post Type called "Offices". I'm using the new Types 3.0-RC2.
Solution: In this case, it appears that the Property Hive plugin has a post type "Offices" that uses the label "Posts", so the Post Relationship was actually set up using the wrong post type. Creating the Post Relationship again using the proper Posts post type solved the problem.
1) Two custom post types: CPT A and CPT B
with one-to-one relationship "CPT A 1to1 CPT B"
2) in the single "CPT A" post, you are going to display related "CPT B" post
Solution:
You can create a view list CPT B posts, filter by:
Select posts in a "CPT A 1to1 CPT B" relationship that are related to the Post where this View is shown
JS errors when edit post with many-to-many relationship
for example:
Uncaught TypeError: Unable to process binding "template: function(){return {afterRender:wpcfVanillaFormValidation} }"
Message: Unable to process binding "visible: function(){return isFieldVisible('post','hero-bg') }"
Message: self.visibleFields(...)[type].includes is not a function
Uncaught TypeError: Unable to process binding "template: function(){return {afterRender:wpcfVanillaFormValidation} }"
Message: Unable to process binding "visible: function(){return isFieldVisible('post','hero-bg') }"
Message: self.visibleFields(...)[type].includes is not a function
Solution:
It is a bug of Types plugin 3.0-RC, and our developers have fixed it in Types plugin 3.0-RC 2
Problem: I would like to sort and filter a View of an M2M post using a custom field on the intermediary relationship post.
Solution: The intermediary post type must be public because the View must query the intermediary post type. Then you can sort or filter by the custom fields of the intermediary post, and use the item attribute syntax to display information about the parent or child post type.
If you already created a relationship and didn’t specify a public intermediary post, you can edit the post type at Toolset > Post Types and change the status of the post type from draft to published. We plan to add the ability to sort and filter a View by fields of other related posts (but not by fields of hidden intermediary posts) soon after M2M stable version is released.
Problem: I would like to filter the options shown in the Post Relationship field in the post editor screen. Only the current User's posts should be shown here.
Solution: There is not a good way to do this in wp-admin, but you can use generic fields in CRED to accomplish something similar.
- Create a CRED form to add posts and insert a generic select field
- Create a View of posts, filtered by author, where the author is the current User
- In the Loop Output editor, insert this code to replace the default wpv-loop tags:
- Change 12345 to match the ID of the View
- Change 67890, 98765 to be a comma-separated list of CRED form IDs (your edit and add CRED forms)
- Place the View of posts inside the options of the generic select field: