Support

Account

Home Forums Front-end Issues Shortcode ACF frontend form Reply To: Shortcode ACF frontend form

  • Hi @buylov

    Here is an example to do it:

    add_shortcode( 'acfNew', 'acf_new' );
    function acf_new( $atts ) {
        ob_start();
        // Attributes
        $atts = shortcode_atts( array(
    	'acfposttitle' => 'false',
    	'acfpostcontent' => 'false'
        ), $atts, 'acfNew' );
        // Start
        acf_form(array(
            'post_title' => $atts['acfposttitle'] === 'true'? true: false,
            'post_content' => $atts['acfpostcontent'] === 'true'? true: false,
            'return'     => '%post_url%',
            'submit_value'  => $acfPostSubmit
        ));
        // End             
        $html = ob_get_contents(); 
        ob_end_clean();
        return $html;
    }

    You can use it like this: [acfNew acfposttitle=true acfpostcontent=true].

    The $atts['acfposttitle'] === 'true'? true: false, is used to convert the string 'true' or 'false' into a boolean type.

    Please learn more the add_shortcode() fucntion here: https://codex.wordpress.org/Function_Reference/add_shortcode.

    Also, you can always hire a developer if you stuck with the issue.

    I hope this helps.