Problem: I have two CPTs, "Landing Pages" and "Services". on the Landing Page CPT, I have a post reference field to link to a Service post. I have created a View of all Services, and I would like to display a link to the related Landing Page.
Solution: Use the post selection tab of the post link dialog to select the reference post. Modify the shortcode to select the proper relationship reference:
Problem:
How to auto fill the parent field with current post ID with Toolset forms
Solution:
You should use value attribute and assign it the current post ID using shortcode [wpv-post-id] in order to auto select the current post ID from parent dropdown select.
For example:
<div class="hide_parent">
[cred_field field='@dom-otzyvy.parent' select_text='--- not set ---' value="[wpv-post-id]" class='form-control' output='bootstrap']
</div>
Problem: I have two custom post types in a M2M relationship, Persons (parent) and Project (child). I have added a custom field to the relationship, and I would like to sort a View of related Project posts using the custom field value. I would like to place that View of related Projects inside another View of Persons, to create a list of all Persons and their related Projects.
Solution:
- Make sure the intermediary post type is set to be visible. Go to Toolset > Post Types and edit the intermediary post type. Set the status to "Publish" and check the Options panel to be sure publicly_queryable, show_ui and show_in_menu are checked.
- Create a View of Projects. In the Loop Output area, insert a shortcode to display the post title.
- Create a View of Persons Projects (the intermediary post type). Set up a post relationship filter. Choose the correct M2M relationship and "related to the current post in the loop". Sort by the custom field value as needed.
- In the Loop Output area of the View insert a shortcode to display the custom field role information.
- Just after the role information, insert another post title shortcode. This time use the Post Selection tab in the popup to select the related Person post as the source of the title. This will display the related Person's name.
- Now insert the View of Persons Projects inside the Loop of the View of Projects, and insert the View of Projects somewhere to test it out on your site.
Problem:
A Form publishes child posts and is shown directly on the parent post. How to set the parent automatically?
Solution:
To automatically set the parent post, you still need to include the parent field but—when the child post form is included on the parent post page—you can pre-set the value by adding the value attribute set to the current post id, something like this:
[cred_field field='@obituaries-condolences.parent' select_text='--- not set ---' class='form-control' output='bootstrap' value='[wpv-post-id]']
The parent field must be included in the form to work. When you don't want your users to see it you can hide it with CSS.