I'm trying to understand what exactly you are aiming to do.
What is the context for where you insert a condition?
Am I correct in thinking you are displaying a Video post (using a template for Videos), but you only want to display the video if it's type is Lecture and also if there are some (any) Posts related to the current video?
Or is that backwards?
And you are starting from the template to display a Post, and you added a View to display Videos that are related to the current Post, but only if they are of the type Lecture?
1. I need a condition in the admin form
"Video type = Lecture (required) have to be linked (have relationship) with Posts (1 or more)"
Editor can not add Video if it Lecture without relationship.
2. In the Post page I would show two block of Video slider: Lecture and Tips.
If I create the two CPT for Video it will be work.
But can it works with one CPT type?
1. I need a condition in the admin form
"Video type = Lecture (required) have to be linked (have relationship) with Posts (1 or more)"
Editor can not add Video if it Lecture without relationship.
Hello, Toolset Types offers limited conditionals for the wp-admin post editor screen. The conditionals offered are all related to showing and hiding specific custom fields, and are based on the values of other custom fields in the same post. The conditionals do not extend to testing for related posts, or custom fields in related posts. I'm not aware of an easy way to set up this type of conditional, not exactly like you have described. If you limit Editor access to wp-admin and force them to use front-end Forms to submit posts, you might be able to set up something using our Forms validation API. The solution would depend on the type of post relationship between Videos and Posts. Can one Post be related to multiple Videos, or can one Post only be related to one Video?
2. In the Post page I would show two block of Video slider: Lecture and Tips.
A View will allow you to filter a list of Videos by a custom field value. So if you plan to build the sliders using Views, you can set up two Views with Query Filters based on the video type custom field: https://toolset.com/course-lesson/creating-a-view/#filter-the-list-of-posts
The topic ‘[Closed] Relation for some post by conditions in different custom post types’ is closed to new replies.