Home Forums Front-end Issues [Badly Need Help] Post not pushing the category


[Badly Need Help] Post not pushing the category

  • Im trying to get my form to push the text from a textfield to set it as the category

    here is my code

    function category_textfield( $post_id ) {
        // Bail early if no ACF data
        if( empty($_POST['acf']) ) {
        //array of category id's
        $categoryIds = array();
         //value of 'date' field is the cat_id
        $cataname = get_field('set_category');
        array_push($categoryIds, $cataname);
        wp_set_post_categories($post_id, $categoryIds);
    add_action( 'acf/save_post', 'category_textfield' );

    but it doesnt seem to work, any suggestions

  • Hi @renshaw

    Kindly have a look at the Pre save hook in acf

    Hopefully this helps.

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

You must be logged in to reply to this topic.