Home Forums ACF PRO Adding Custom Input Field for \"Other Contribution\"


Adding Custom Input Field for \"Other Contribution\"

  • I am using ACF plugin for the first time and I was able to successfully display a Sponsor to my front page. But now I am trying to add a custom input field as,

    Other Contribution: <text box that accepts numbers>

    The user should be able to enter some amount in the above text box. And on the next page I retrieve the value entered by the user and use it.

    I created a new “Field Group” as “Other Contribution” and added a field to it as “Additional Contribution” with field type as ‘Number’ and Location Rule as “Post Type is equal to post”. Then I added the following code to functions.php but the home page doesn’t load completely. It displays the heading “Registration” and nothing else below it.

    function ee_event_contribution()
    <div id=”primary”>
    <div id=”content” role=”main”>

    <?php /* The loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <?php acf_form(array(
    ‘post_id’ => ‘new’,
    ‘field_groups’ => array(122),
    ‘new_post’ => array(
    ‘post_type’ => ‘event’,
    ‘post_status’ => ‘publish’),
    ‘submit_value’ => ‘Update the post!’
    )); ?>

    <?php endwhile; ?>

    </div><!– #content –>
    </div><!– #primary –>
    add_action( ‘AHEE_event_details_after_the_content’, ‘ee_event_contribution’ );

    I also added <?php acf_form_head(); ?> to the beginning to the file functions.php

    If someone has done something similar, I would appreciate their help!

  • Hi @mail4priyanka

    Thanks for the post.

    The issue might be with the loading order of the scripts.

    It is also recommended for the acf_form_head() function to be at the very top of your template where you are calling the values of the contribution post type and not in your functions.php file.

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

The topic ‘Adding Custom Input Field for \"Other Contribution\"’ is closed to new replies.