Home › Forums › Front-end Issues › Front-end acf_form() no CPT title
My front-end forms render, submit and create new CPT’s just like I want them to. However, the newly created CPT does not have a title.
When I try to call the new created CPT from different CPT using the Post Object or Relationship fields, the CPTs are listed but only itemized as “untitled.”
I am using this code in my functions file to create the_title using get_the_author(). On the back-end this successfully displays the CPT title as the post author. But the “the_title” cannot be called from the front-end and shows only as “untitled” in Post Object / Relationship fields.
function agsm_custom_admin_titles( $title, $post_id ) {
global $post;
$output = $title;
if( isset($post->post_type) ):
switch( $post->post_type ) {
case 'student_profile':
$studentid = get_field('student_willamette_u_id', $post_id );
$output = $studentid;
break;
}
switch( $post->post_type ) {
case 'internship':
$internid = get_the_author();
$output = $internid;
break;
}
switch( $post->post_type ) {
case 'evaluation':
$evalid = get_the_author();
$output = $evalid;
break;
}
endif;
return $output;
}
Any ideas out there on what I’m missing here?
When calling acf_form() you can set the “post_title” setting to true. This will add a field for adding the post title https://www.advancedcustomfields.com/resources/acf_form/
If you want this field to be dynamically generated then you need to add an acf/save_post action that updates the post with your desired title. https://support.advancedcustomfields.com/forums/topic/using-acf_form-add-post-title/
Haven’t tried this solution yet but wanted to let you know I received the info and after a quick look I think this will be the key. It looks right to me. Will give it a try later today to confirm. Thank you for your fast and clear response. Much appreciated.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.