Problem:
How to show fields from parent posts when creating a PHP template for child posts?
Solution:
When you create templates with Views or Layouts you can set the context to the parent post when outputting fields with the id shortcode attribute.
You can employ a similar technique when directly editing PHP templates with the types_render_field function, passing the ID attribute as an array:
In my site i have custom post type contacts, every contact can attend to 1 or more courses (usually 1 to 5). We'll plan to have 10.000-30.000 contacts.
Instinctively i was thinking to use method of advanced custom field and add repeater fields (course type, level, date, ecc...)
I read also some post on this forum, and some article from toolset documentation on group fields (many to many relationship or one to many)
I'm a little confused on options and my question is:
in my case what is the correct option i should use with toolset (especially from database point of view)?
Solution:
It depends on your settings.
I assume we are talking about this case:
Two custom post types:
- contacts
- courses
One "courses" post can connect with multiple "contacts" posts
One "contacts" post can connect with multiple "courses" posts
If it is, I suggest you try to setup many-to-many relationship between custom post types:
- contacts
- courses
see our document:
Problem:
It is not possible to edit custom fields groups.
This is on a site with betas of Types and Views, and Access.
Solution:
The Types and Views betas that are part of the post relationships update do not currently work with other Toolset plugins reliably and are intended only to be used together. This limitation will be removed when they move out of beta.
Problem: I have 3 post types in a child -> parent -> grandparent hierarchy relationship. I would like to display information about the parent and grandparent in the child post.
Solution:
Access information about a parent post, you can use the following syntax:
[wpv-post-title id="$parent-type-slug"]
So for example, if your city post type slug is "city", then your code will be:
[wpv-post-title id="$city"]
To access information about a grandparent post, you can use a Content Template to change the context by passing in the $city operator for the id attribute:
Inside that Content Template, you can then use the parent post technique we used before to access the grandparent country post. If your country post type slug is "country" then your code in the Content Template will be:
I have two post types, State and City. We have a top Page, then a child of State, then a child of City.
Could you help me figure out how to get the "Parent" option to show the correct items? When I edit a State, "Parent" should show all Pages. Then, when I edit City, "Parent" should show all States.
Currently, it is only showing its own CPT.
Solution:
I suggest you setup the post type "State" as parent post type of "City", then when you edit a single "City" post, you will be able to setup it's parent "State" post, see our document:
The issue here is that the customer had stored some id in a custom field of another CPT but wanted to know if its possible to use Views to filter on his secondary view to show his Post Parent essentially.
Solution:
In this scenario we will be using Products and Beans where products has the custom field that stores the ID of the beans.
So essentially when you're on the bean's page you want to display the products?
In this case you will need to create a view for the product cpt and then add a filter for the custom field that has the bean id in it.
Then set that field so that the value is retrieved using a shortcode attribute. Next all you need to do is to add the view to the bean page and then pass the ID of the page into the view like this.
I have a relation with post author and a custom field set. I can make every field required (I do not need to, but I can), except for the post author field.
As the client is testing it now an empty line appeared in the dropdown. I have no direct contact with the client so I can not ask him what happened, but I think making the field required could avoid empty lines in the future. Maybe I am thinking wrong, but now you can make a new order without selecting the author.
Solution:
How do you setup the post author field? is it a CRED generic field?
If it is, you can add argument "required" in the shortcode [cred_generic_field], for example:
Problem: I have a CRED form that allows users to create child posts. I would like to predefine the parent post so the User does not need to select it.
Solution: If you want to predefine values for a CRED field, you have 3 basic options:
1. Provide the value as a URL parameter. Link to the page containing the CRED form using the URL value to supply the correct parent ID, something like yoursite.com/cred-form-page?contatti=1234. Then update your parent contatti CRED field and add the urlparam attribute:
This would predefine the contatti with ID 1234 as the parent of the new post.
2. Provide the value in the value attribute. You can use a hard-coded number or a shortcode in the value attribute to predefine the parent contatti ID:
3. Write your own custom code with JavaScript and/or PHP. Note that there is no CRED JavaScript API, so the amount of support we can provide for custom JavaScript is fairly limited.
In all 3 cases, you can wrap the field in a hidden div if you want to hide the field from your Users: