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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.