How to display custom Wordpress acf fields at the beginning of a form

In my project, I need to display custom message field fields on the front side, so I installed ACF and created a custom feed, now my problem is how to display these fields with HTML ???? I used the get_fields () function, but it does not display HTML code.

+3
source share
5 answers

If you want to show the fields inside the message, you need to put the code inside the "single.php" loop, assuming that you are using the standard message type.

This code retrieves only the field, it does not display anything, it is used to store the value in a variable:

get_field('field-name');

, :

the_field('field-name');

, .

:

echo get_field('field-name')

$myfield = get_field('field-name');
echo $myfield;
+1

...

,

$options = array(
    'post_id' => $post->ID, // post id to get field groups from and save data to
    'field_groups' => array(), // this will find the field groups for this post (post ID of the acf post objects)
    'form' => true, // set this to false to prevent the <form> tag from being created
    'form_attributes' => array( // attributes will be added to the form element
        'id' => 'post',
        'class' => '',
        'action' => '',
        'method' => 'post',
    ),
    'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
    'html_before_fields' => '', // html inside form before fields
    'html_after_fields' => '', // html inside form after fields
    'submit_value' => 'Update', // value for submit field
    'updated_message' => 'Post updated.', // default updated message. Can be false to show no message
);
acf_form( $options );

, ...

0

, ,

0

:

<?php
/**
 * Template Name: Resume Build
 *
 * @package Betheme
 * @author Muffin Group
 */
?>
<?php
/**
 * The main template file.
 *
 * @package Betheme
 * @author Muffin group
 * @link http://muffingroup.com
 */
acf_form_head();
get_header();


?>


<!-- #Content -->
<div id="Content">
    <div class="content_wrapper clearfix">

        <!-- .sections_group -->
        <div class="sections_group">

            <div id="content">

    <?php

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

    ?>

</div>



        </div>  

        <!-- .four-columns - sidebar -->
        <?php get_sidebar( 'blog' ); ?>

    </div>
</div>

<?php get_footer();

// Omit Closing PHP Tags
0

All Articles