Support

Account

Home Forums Front-end Issues Adding a post from the frontend

Solved

Adding a post from the frontend

    • luor

    • November 23, 2019 at 11:16 pm

    Hi.
    how should I assign a post from user frontend from acf relations field to a custom category

    use:

    acf_form and tax_input or add_action acf/save_post ?

  • That depends the value you want to store.

    If the post can only have one term in the custom taxonomy, or you want to overwrite any terms already assigned to the post, the you can use an ACF taxonomy field.

    On the other hand, if you want to append the term to the other terms already assigned to the post the you need to use acf/save_post and call wp_set_post_terms() https://developer.wordpress.org/reference/functions/wp_set_post_terms/ with $append set to true.

    • luor

    • November 26, 2019 at 3:35 am

    Ok. thanks.

    I have custom_field offer_category – this field isto be taxonomy

    I have page add-post.php with acf_form_head();
    and I have the code below:

    
    <?php acf_form(array(
    	'post_id'  => 'new_post',
    	'uploader' => 'basic',
    	'return'  => '%post_url%',
    	'updated_message'  => 'Post saved!',					
    	'new_post' => array(
    		'post_type' => 'offer',
    		'tax_input' => array('typ' => array($_POST['acf']['field_ID_RELATION_TAX_FIELD'])),	
    		'post_status'		=> 'draft',						
    	),
    	'submit_value'		=> 'Add'
    )); ?>
    
    

    and whole post is being saved but is not affiliated with my custom taxonomy

    • luor

    • November 27, 2019 at 10:44 pm

    Hey, no one will advise ??? 🙂
    where do I make mistake ?

    • luor

    • November 29, 2019 at 3:57 am

    … i found error…

    everything works on standard acf_form()

    I didn’t select button save taxonomy terms….

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

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.