Support

Account

Home Forums General Issues How to Create Custom Template for New Post

Helping

How to Create Custom Template for New Post

  • I have a custom post type called ‘Question’. I can create new ‘Questions’ using the address wp-admin/post-new.php?post_type=question but this form is not pretty enough.

    I have created the single-question.php template file for display of the questions once they have been created, and have customisedd the html for existing questions. All of the ACF fields display nicely.

    However, I can’t work out how to customise the initial data entry page for new posts.

    What is the best way to do this?

    I have created a ‘dummy’ wordpress page with slug ‘enter-new-question’, and created a html template file, and linked that template file to display that page, but while I can put a text editor page in using wp_editor(), I can’t work out how to make editable fields display for the title or acf fields in that template. I was planning to capture the submission inside the wordpress post.php file and created the new question there – but I need the title.

    Has anyone worked out a way to create a pretty data collection form containing ACF fields and WordPress’s title, that creates a new custom post type?

    Thanks in advance.

  • Hi @autefrum

    You should be able to use the acf_form() function. With this function, you can set the “post_title” option to true to show the post title field. So, it should be something like this:

    acf_form(array(
        'post_id'        => 'new_post',
        'post_title'    => true,
        'new_post'        => array(
            'post_type'    => 'question',
            'post_status'    => 'publish'
        )
    ));

    This page should give you more idea about it: https://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/.

    I hope this helps 🙂

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘How to Create Custom Template for New Post’ is closed to new replies.