CRED plugin allows you to build forms that create child posts and set parents for these posts, supporting the parent-child relationship functionality from Types plugin.
When you ask for help or report issues, make sure to tell us the structure of your content and the relationship between the content types.
Viewing 15 topics - 646 through 660 (of 660 total)
Problem:
How to display any post field from CRED Form's Parent
Solution:
To display custom field of parent you should use Types shortcode:
[types field="xxxx" id="$yyyy"][/types]
Where:
- xxxx is the field of the parent you want to show, and yyyy is the slug-name of the parent. The “$” is required, as this represents a variable where the parent post name will be replaced by the post ID, internally.
The issue here is that the user had created a CRED form with many custom fields added through CRED but they were not being saved to the post.
Solution:
The solution is that the user should create the custom fields in Types and then Regenerate the CRED form so that the created fields can be reflected on the form.
Problem: I am using cred_save_data to perform some actions after form submission, but the update_post_meta calls do not seem to be working as expected.
Solution: Check your code syntax, compare $_POST keys, and debug using the server logs.
Problem: I am using CRED to create child posts. I would like to programmatically set the child post title based on the parent post title. I'm using the beta plugins.
Solution:
The post data key for accessing the parent post's ID has changed in the M2M betas. You can now use the format "@" + relationshipslug + "_parent". In this case the relationship slug is member_visitation, so the key is "@member_visitation_parent".
add_action('cred_save_data', 'copy_parent_title_to_child',10,2);
function copy_parent_title_to_child($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==429)
{
if (isset($_POST['@member_visitation_parent']))
{
$my_post = array(
'ID' => $post_id,
'post_title' => get_the_title($_POST['@member_visitation_parent'])
);
wp_update_post( $my_post );
}
}
}
Problem: I have a CRED form that includes a Category select field. I would like to include top-level terms in one field, then sub-category terms in another field.
Solution: Category selection in CRED is not split up into multiple hierarchical levels like this - only a single select field is used. If you want to modify this behavior you can build custom generic fields, apply CRED conditionals, and use the cred_save_data API to apply the selected terms. Here is the general idea:
- Create a generic select field that includes options for each top-level category. The value for each option should be the slug of that category term.
- Create a generic select field that includes all the subcategories for one top-level category. The value for each option should be the slug of that subcategory term.
- Use CRED conditionals to hide the subcategory select field until the top-level category with the correct slug has been chosen.
- Create more generic select fields and CRED conditionals for each top-level category.
- Use the cred_save_data hook to capture all the selected categories and subcategories, and use the WordPress API set_object_terms to add the selected terms to the new post created by CRED.