Problem:
How to display data or field from a Parent post on a CRED form that creates a Child post? I want to add a specific field from the parent post which is a Date field.
Solution:
1. Please add following code in your theme’s or child theme’s functions.php file:
add_shortcode('cred_parent_field', 'cred_parent_field_func'); function cred_parent_field_func($atts) { extract( shortcode_atts( array( 'id'=>null, 'field' => null, 'format' => null ), $atts ) ); $parent_id=null; if ( isset($_GET['parent_'.$id.'_id']) ) { $parent_id=intval($_GET['parent_'.$id.'_id']); } return do_shortcode( '[types field="' . $field .'" format="'. $format . '" id="'. $parent_id . '"][/types]'); }
2. Add this shortcode in your child post form:
[cred_parent_field field="assigned-hours" format="FIELD_NAME: FIELD_VALUE" id="program"]
In above shortcode:
==> Replace field="assigned-hours" with your field name
==> Replace id="program" with your Parent CPT slug
==> For Date field format, you can change format value as: format="m-d-Y"
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | 12:00 – 17:00 | - |
- | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | 18:00 – 21:00 | - |
Supporter timezone: Asia/Karachi (GMT+05:00)
This topic contains 3 replies, has 2 voices.
Last updated by 7 years, 4 months ago.
Assisted by: Noman.