Aleš Sýkora wrote

Auto-populate child content with parent content’s title

11. 7. 2019 in

Snippet from our fan, who do not give us his name, just call him Another Unknown Toolset Fan.

This code also allows you to add the current date. If you do not want/need to display the date in the title, simply remove the shortcode, as well as well as the relevant code from the ‘post-title’ line.

// Display Current Date
add_shortcode('wpv-post-today', 'today_shortcode');
function today_shortcode() {
return date( 'F j, Y', current_time( 'timestamp' ));
}
// Auto Populate Repair
add_action('cred_submit_complete', 'auto_populate_title',10,2);
function auto_populate_title($post_id, $form_data){
// Edit form ID to match your form's ID
if ($form_data['id']==888) {
$parentpost_id = toolset_get_related_post($post_id, 'membership-vehicle-repair' );
$parent_title = get_the_title($parentpost_id);
$today_date = current_time( 'Y-m-d' );
$childpost_title = array(
'ID' => $post_id,
'post_title' => $parent_title . ' - ' . $today_date,
);
wp_update_post( $childpost_title );
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

More from category
Aleš Sýkora wrote
Woocommerce Bootstrap 4 CSS Columns Cart Fix
8. 10. 2019 in
Woocommerce uses same CSS classes for their cart columns. It makes some problems with Bootstrap 4. Easy way to fix it.
Read More
Aleš Sýkora wrote
Use custom Javascript on form submission with Fluent Forms
15. 6. 2021 in
If you need to use your custom script on form submission and using Fluent Forms, use this code in your form’s custom JS settings.
Read More
Aleš Sýkora wrote
Flickity carousell same height slides fix
24. 3. 2021 in
If you need all your slides to have same height, add the CSS selector to your slider cells and use this code in your CSS: Do not forget to add the cellSelector attribute to your flickity slider setup:
Read More
magnifiercross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram