Written by: Aleš Sýkora

The Author of Toolset.wiki. Big fan of Toolset plugins and WordPress.

I am big fan of WordPress and Toolset plugins. I have done many projects based on WordPress. I also have experience with online marketing, PPC advertising and SEO. I live in Czech Budweis – the town of Budweiser Budvar breverage in the south of the Czech Republic – the heart of Europe.

I love skateboarding, snowboarding, frisbee, fitness, healthy lifestyle, tattoos, mountain biking and other sports. I enjoy having time with friends with good beer and good music.

Auto-populate child content with parent content’s title

Last Update: 10. 11. 2019 , Category:

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 );
}
}

Support Us via our Affiliate link!

Toolset logo WordPress

What to do next?

Need a Toolset License?

Buy via affiliate link!

Looking for a tutorial?


Help other users – Add your snippet!


Join the discussion!