Support

Account

Forum Replies Created

  • I have a while loop that displays the list of custom posts with ACF. There’s a ‘Edit Post’ button beside every list item.

    The ‘Edit Post’ button should pop up a modal on click. However, I am unable to target the post_id for the different list items. I am assuming this is covered under “Displaying within an AJAX Modal’ in https://www.advancedcustomfields.com/resources/acf_form/. But I can’t figure out where the acf_enqueue_uploader(); should sit, or how my JS file shile be configured.

    Can someone help?

    while($userRecipes->have_posts()) {
              $userRecipes->the_post(); ?>
                <li class="recipe" data-id="<?php the_ID();?>">
                  <a href="<?php the_permalink()?>"><h3 class="recipe-title"><?php echo esc_attr(get_the_title()); ?></h3></a>
                  <span type="button" data-toggle="modal" data-target="#myModal" class="edit-recipe"><i class="fa fa-pencil"></i> Edit</span></a>
                  <span class="delete-recipe"><i class="fa fa-trash-o"></i> Delete</span>
                  <div class="recipe-page-display">
                    <img class="recipe-page-image" src="<?php the_field('food_images'); ?>">
                    <div><?php echo wp_trim_words(esc_attr(get_the_content()), 50); ?></div>
                </li>
            <?php }
    <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">Modal Header</h4>
            </div>
            <div class="modal-body">
              <div id="primary">
            <div id="content" role="main">
              <?php 
                acf_form(array(
                'post_title' => true,
                'post_content' => true,
                'post_id'       => $post_id, This is where it fails
              )) ?>
              <span class="edit-recipe"><i class="fa fa-times"></i> Cancel</span>
            </div>
          </div>
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
          </div>
Viewing 1 post (of 1 total)