Support

Account

Forum Replies Created

  • I followed what James was saying and used the $_GET method. Here’s how I made it work, hopefully it will help someone:

    (I’m assuming you know how to create WordPress page templates, and know how to create ACF submit forms)

    1. Add a button on your single.php that sends the post id with $_GET to a page that we will create next:

    global $post;
    $postID = $post->ID; ?>
    		
    <a href="./page-with-form/?post=<?php echo $postID; ?>">Edit Post Button</a>

    2. Create a page template with the ACF form in it. This page from the ACF documentation has an example on how to edit a specific post with a form. You’ll just have to set the post id dynamically in this case. This is what my form looks like:

    <?php acf_form(array(
        'post_id'	   => $post_id, //Variable that you'll get from the URL
        'post_title'   => true,
        'post_content' => true,
        'fields' => array('_thumbnail_id', 'ask_for_donations'),  //The name of the custom fields I want to show on the form              
        'submit_value' => 'Update Content',
        'return' => '%post_url%' //Returns to the original post
    )); ?>

    3. To read the post id that has been passed on the URL (will look like: ?post=number) add the following line on the page template somewhere before the form starts:
    $post_id = $_GET["post"];

Viewing 1 post (of 1 total)